usleep 休眠非man描述的微妙而是毫秒级别的!
centos 5.4 系统。gcc 4.1.2
nanosleep 和 usleep 休眠级别都是毫秒,而不是man描述的纳秒和微妙。。。为什么会这样?
分享到:
------解决方案--------------------
这个linux是支持的,只是有点点不准确而已。毕竟纳秒单位很小嘛。
------解决方案--------------------
你可以写个程序测试, 用nanosleep 去睡 1000*1000*100,肯定是睡100ms左右。
------解决方案--------------------
nanosleep和usleep的精度都是有限的,一般都在毫秒级别。
关于usleep是这么说的:
The usleep() function will cause the calling thread to be suspended from execution until either the number of real-time microseconds specified by the argument useconds has elapsed or a signal is delivered to the calling thread and its action is to invoke a signal-catching function or to terminate the process. The suspension time may be longer than requested due to the scheduling of other activity by the system.
Implementations may place limitations on the gra
最后
以上就是高兴咖啡豆最近收集整理的关于linux休眠毫秒命令,usleep 休眠非man描述的微妙而是毫秒级别的!该如何处理的全部内容,更多相关linux休眠毫秒命令,usleep内容请搜索靠谱客的其他文章。
发表评论 取消回复