- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
来自 here :
The value of HZ varies across kernel versions and hardware platforms. On i386 the situation is as follows: on kernels up to and including 2.4.x, HZ was 100, giving a jiffy value of 0.01 seconds; starting with 2.6.0, HZ was raised to 1000, giving a jiffy of 0.001 seconds. Since kernel 2.6.13, the HZ value is a kernel configuration parameter and can be 100, 250 (the default) or 1000, yielding a jiffies value of, respectively, 0.01, 0.004, or 0.001 seconds. Since kernel 2.6.20, a further frequency is available: 300, a number that divides evenly for the common video frame rates (PAL, 25 HZ; NTSC, 30 HZ).
那么如何将 5usec
转换为 jiffies
?
extern unsigned long usecs_to_jiffies(const unsigned int u);
它似乎没有用,因为 jiffies 分辨率不够高,无法测量 useconds。
最佳答案
如有疑问,请阅读代码!
在这里(可以找到它的一个版本 here ):
unsigned long usecs_to_jiffies(const unsigned int u)
{
if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET))
return MAX_JIFFY_OFFSET;
#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ);
#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
return u * (HZ / USEC_PER_SEC);
#else
return (USEC_TO_HZ_MUL32 * u + USEC_TO_HZ_ADJ32)
>> USEC_TO_HZ_SHR32;
#endif
}
因此,它会做一些事情来检查是否有快捷方式,如果没有其他方法,则使用一些 64 位数学计算出来。
但是 5usec 将是一个 jiffies,无论它运行哪一段代码。
关于c - 如果 jiffies 的分辨率为毫秒,usecs_to_jiffies 如何将 usecs 转换为 jiffies?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14678709/
以下几行摘自 RFC6528. S3 提议的初始序列号生成算法。 TCP 应该使用以下表达式生成其初始序列号: ISN = M + F(localip, localport, remoteip,
来自 here : The value of HZ varies across kernel versions and hardware platforms. On i386 the situatio
POSIX 使用struct timeval 来表示时间间隔。 struct timeval { time_t tv_sec; unsigned tv_usec; }; GHS I
我是一名优秀的程序员,十分优秀!