sleep API longer than expected time

Copyright notice: reproduced please specify blog address https://blog.csdn.net/jinron10/article/details/86647834

[The DESCRIPTION]
user Space, many are likely to use the API to lsleep related funciton. The API can only guarantee sleep time is longer than the
user expectations many cases if long, will have a relatively large impact on user. This FAQ can help you The reason to debug

[SOLUTION]
a lot of sleep related fuction most always achieved by hrtimer kernel of. The hrtimer implementation of key variables affecting a subject.
Is tsk-> timer_slack_ns, this variable is the equivalent of a priority. For example, user sleep is 10ms. But timer_slack_ns value is 50ms. So sleep time will be more than 50ms, rather than the user expected 10ms, defualt value timer_slack_ns each tsk is 5000ns, user can adjust according to their own needs. google has set policy through different slack values for different thread. So sometimes when you use the sleep-related API in certain task, the emergence of a sizeable gap.

But you can thread or process you need thereof. In the modified self-init fetch the corresponding API can refer to:.
The prctl (PR_SET_TIMERSLACK, 5000, 0, 0, 0); // add this line
refer to the man page: http://man7.org/linux/man-pages/ man2 / prctl.2.html PR_SET_TIMERSLACK
 

Guess you like

Origin blog.csdn.net/jinron10/article/details/86647834