79253648

Date: 2024-12-05 06:56:37
Score: 2
Natty:
Report link

Both usleep(1) and usleep(0) need to make system calls and undergo two scheduling (the first time is to be deprived of the CPU, and the second time to regain the CPU). For such a process, it is generally greater than 1us.

The kernel timer will re-awaken your test program exactly after 0us and 1us. At this time, your test program may even be completing the first context switch? So for your test program, one usleep(0) and one usleep(1) take the same time.

Reasons:
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: liqiang2020