- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试确定软件中 struct stat
的 st_mtim.tv_nsec
字段对于特定目录/文件系统的有效精度。
有没有一种方法可以确定文件系统的修改时间精度(而不是库的“纳秒”精度或操作系统的目录缓存精度)?
添加:对于一些背景信息,这是用于更新某些文件的工具。基本场景是:“如果第一组文件中的某个文件可能比第二组文件中的任何文件都新,则使用第一组文件更新第二组文件”后跟“如果第二组文件中的某个文件可能比第三组文件中的任何文件都新,则使用第二组文件更新第三组文件”。 p>
我遇到的问题是第一次运行该工具时(修改第一组中的文件后)它会更新第二组文件,然后更新第三组文件(这是正确的行为);但是第二次运行该工具(当没有任何更改时)第二组文件和第三组文件将具有相同的时间戳,因此它必须假设第三组中的文件可能更新并且它会更新第三组文件莫名其妙。
为了解决最初的问题,我在更新第三组文件之前引入了延迟(“nanosleep();”);这样下次运行该工具时,第三组文件会稍微旧一些。这确实避免了不必要的更新。
当然不是那么简单 - 存在任意数量的相互依赖的“文件组”(不仅仅是 3 组)。
这让我想到了我当前的问题 - 对于某些文件系统,时间戳精度低至 2 秒,并且所需的“最坏情况”延迟非常大(例如,它加起来至少有 60 秒的延迟 31 “文件组”)的级别。对于大多数文件系统,时间戳要精确得多,大量浪费的时间可能会消失。当然,该工具旨在“尽可能便携”,我无法真正对时间戳精度做出任何假设(如果我知道文件系统总是 ext4 或其他东西,那将非常容易) .
最佳答案
根据这个OpenGroup Link ,
The resolution of timestamps of files in a file system is implementation-defined, but shall be no coarser than one-second resolution. The three timestamps shall always have values that are supported by the file system. Whenever any of a file's timestamps are to be set to a value V according to the rules of the preceding paragraphs of this section, the implementation shall immediately set the timestamp to the greatest value supported by the file system that is not greater than V.
所以你保证它至少是一秒钟。
此外,根据 stat(2) 上的 Linux 手册页:
Since kernel 2.5.48, the stat structure supports nanosecond resolution for the three file timestamp fields.
关于c - 确定 "stat()"返回的有效时间戳精度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6849609/
关于这个话题已经说了很多,但是我找不到我的问题的确切答案。 JavaScript 无法准确表示 0.1 等小数,这是可以理解的。 例如,由于乘法运算期间发生舍入误差,这是正确的: 0.1 * 3 ==
在 zig 中,可以使用“{d}”以十进制表示法打印浮点值。这将自动以全精度打印该值。有没有办法指定位数?是针对每个值,还是作为某种全局设置? 最佳答案 这将限制小数点后的位数,四舍五入和零填充: f
我正在进行的项目需要高精度。减法时我遇到的问题在这里说明: >> 1-0.9999999999999999 ans = 1.1102e-16 >> 1-0.99999999999999999 ans
是否可以使变量本身的精度成为将在运行时定义的变量? 说,如果我尝试编译: SUBROUTINE FOO( VARIABLE, PRECISION_VALUE ) IMPLICI
我正在查询 SQLite 数据库以获取纬度/经度详细信息。 SELECT * FROM tblMain where latitude > -33.866 and latitude 151.20
我一直使用下划线将整数定义为 Fortran 中的特定类型。 下面是一段代码,用于演示 1_8 的含义,例如: program main implicit none integer(2)
我正在寻找一种方法来告诉 pint 要打印多少个有效数字。例如,当我输入以下内容时: import pint ureg = pint.UnitRegistry() print(3*ureg.m /9)
我正在从事一个项目,目标是从山上追踪动物。在第一个实地考察季中,我们使用了 OpenTags 和经过校准的摄像头,虽然可以正常工作,但需要大量的处理/校准,而且至关重要的是,当系统出现问题时无法提供任
在 JavaScript 中有没有一种方法可以确定一个数除以另一个数是否会得到整数?就像 18.4/0.002 给我们 9200,但是 18.4/0.1 给我们 183.99999999999997。
我正在尝试使用 Big.js 在 javascript 中完成此计算 r = (a * b)/ sqrt( ( a*sin(θ) )^2 + ( b*cos(θ) )^2 ) 我也试过 math.js
我有这个片段着色器代码,它在 iOS 模拟器(非视网膜)和 iPad2(非视网膜)之间显示不同: highp vec2 textCoord; textCoord.x = gl_Fr
这个问题在这里已经有了答案: C++ calculating more precise than double or long double (2 个答案) 关闭 6 年前。 是否有任何浮点类型在小
我似乎一直困惑的三个问题: 为什么代码是 x & ~077比这行代码 x & 0177700 更好。是因为精度损失较小吗? 为什么此代码对于设置数字中的第 5 位不正确? num = num + 0x
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Precision of Floating Point 我正在尝试使用一些 float 来计算概率,但我的最
由于微 Controller 的精度,我定义了一个包含两个 float 比率的符号,而不是直接写结果。 #define INTERVAL (0.01F/0.499F) 代替 #defi
我试图比较这 3 种搜索算法,起初我使用 time.h 库但没有任何反应,输出始终是 0.00000 秒。现在我试图在循环中使用一些计数器。但我在这里也有问题, 任何人都可以帮我处理代码吗? 这是我的
char buf[10]; int counter, x = 0; snprintf (buf, sizeof buf , "%.100d%n", x, &counter); printf("Coun
我注意到在评估向量时对我来说是不可预测的行为。直接执行它与在循环中进行索引似乎是完全不同的。谁能帮我解决这个问题?我知道可能在它如何进行每个操作中都有解释,所以我需要一些关于如何查找它的键 多谢指教提
我想在我的应用程序中使用精确的 gps 定位。所以我遵循了一个简单的教程(LocationManager 的基本用法,明确要求 GPS 提供商,要求更新 0 ms,0 m)并创建了一个应用程序。我对更
float 在 1.0f 和 0.0f 之间有多少位精度,这样每个值都可以唯一表示? 例如,如果第一个小数 float 不能表示 0.13f,答案就是 float 只有一位精度。 最佳答案 std::
我是一名优秀的程序员,十分优秀!