I am working on a project that requires a semi accurate usleep/nanosleep timer implementation. My project is in the works so I cannot disclose it's nature or operation, however it's going to more than likely just use either nanosleep/usleep with decent precision. Most of all Linux/*BSD systems provide at least 1ms timers, however they give significant jitter (around 2000us)
I require a timer that either uses something like this:
- RDTSC based {nano,u}sleep timer (is this possible?)
- HPET based {nano,u}sleep timers (is this possible?)
- Some other way to get accurate time, ie: wrapping gettimeofday into a function?
- Any other methods?
This code will more than likely be rolled into either kernel or userland depending on the coders needs/desires. However, I do intend on it going into at least libc (replace the usleep function, as that is what we use, and usleep calls nanosleep)
## Deliverables
If possible, please provide some sort of benchmark tool so I can see how accurate it really is. I know this depends on the OS etc, however I'm pretty sure we can get really accurate timing without any issues.