usleep accuracy
Open
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
I am using a simple usleep(100); and I noticed that the actual delay is 140 us. My specific configuration is a tickless scheduler where USEC_PER_TICK is 1.
For comparison I have setup a thread that waits on sigwaitinfo(&mask, &info);, which is signaled by a hardware timer with a timeout of 100 us. Using clock_gettime() for timing I see that this approach almost gets precisely done what I am expecting.
From what I am understanding usleep employs signals as well under the hood, however using clock_systime_ticks() for analysis it seems that it performs significantly worse. Is this expected due to the overhead?
Contributor guide
Assessment
This issue has not been assessed yet.