What's the algorithm behind sleep()?

后端 未结 8 1913
灰色年华
灰色年华 2020-12-07 16:36

Now there\'s something I always wondered: how is sleep() implemented ?

If it is all about using an API from the OS, then how is the API made ?

Does it all bo

8条回答
  •  悲&欢浪女
    2020-12-07 17:22

    A multitasking operating system has a component called a scheduler, this component is responsible for giving CPU time to threads, calling sleep tells the OS not to give CPU time to this thread for some time.

    see http://en.wikipedia.org/wiki/Process_states for complete details.

提交回复
热议问题