nanosleep high cpu usage?

前端 未结 2 802
忘掉有多难
忘掉有多难 2020-12-30 14:51

I noticed that a little test program which calls nanosleep is showing a huge difference in CPU usage when run on Linux machines with a kernel newer than 2.6.22.



        
2条回答
  •  梦毁少年i
    2020-12-30 15:21

    I don't have a definitive answer... but the first thing I would look at is the config options with which the kernel was compiled:

    cat /boot/config-`uname -r`
    

    Options that I think might be relevant are CONFIG_HZ, CONFIG_HPET_TIMER and CONFIG_HIGH_RES_TIMERS. Maybe those differ among your kernels... that might help you narrow it down.

    It used to be on 2.4 kernels that nanosleep would busy-wait for waits of under 2 ms if running under real-time scheduler policies (SCHED_FIFO or SCHED_RR, see the nanosleep man page), but since all of the kernels are 2.6, that doesn't seem to be a factor.

提交回复
热议问题