- 论坛徽章:
- 7
|
本帖最后由 cxytz01 于 2013-07-31 17:52 编辑
楼主看看这篇帖子以及man或许有帮助。
我之前遇到过sleep 200ms的,结果概率性出现1~6s线程不执行,不是死锁,后来不了了之。但是换了新型板子之后,再也没出现过。这个问题取决于Hardware Clock,不是software clock决定得了的,应用层定时器总会出现一段jiffy延时。当然还有内核,得看看内核支持的精度。
http://stackoverflow.com/questio ... leep-on-cent-os-6-3
man 7 time
Real time and process time
Real time is defined as time measured from some fixed point, either from a standard point in the past (see the description of the Epoch and
calendar time below), or from some point (e.g., the start) in the life of a process (elapsed time).
Process time is defined as the amount of CPU time used by a process. This is sometimes divided into user and system components. User CPU time
is the time spent executing code in user mode. System CPU time is the time spent by the kernel executing in system mode on behalf of the pro-
cess (e.g., executing system calls). The time(1) command can be used to determine the amount of CPU time consumed during the execution of a
program. A program can determine the amount of CPU time it has consumed using times(2), getrusage(2), or clock(3).
The Hardware Clock
Most computers have a (battery-powered) hardware clock which the kernel reads at boot time in order to initialize the software clock. For fur-
ther details, see rtc(4) and hwclock( .
The Software Clock, HZ, and Jiffies
The accuracy of many system calls and timestamps is limited by the resolution of the software clock, a clock maintained by the kernel which
measures time in jiffies. The size of a jiffy is determined by the value of the kernel constant HZ. The value of HZ varies across kernel ver-
sions and hardware platforms. On x86 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 con-
figuration parameter and can be 100, 250 (the default) or 1000, yielding a jiffies value of, respectively, 0.01, 0.004, or 0.001 seconds. |
|