Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can already do this in POSIX.1-2001-conforming systems like Linux using `clock_nanosleep` (http://man7.org/linux/man-pages/man2/clock_nanosleep.2.html).


Still just a Sleep(), right? So the latency in the callback can be added to the next time, with resulting drift. The idea is, I know when I want to be called back, as an actual number. I want a sleepuntil() that I pass the actual time.


Unless I misunderstood, that's what the TIMER_ABSTIME option is for. This is actually what I use for soft real-time loops, when I'm concerned about both drift and jitter.


Ok thanks, I reread it, that seems to be the case! I hope the seconds field is honored along with ns. WinCE had a bug where they used a long. If latency made your call for a small interval occur after the interval had elapsed, you slept for 19.5 minutes instead (nearly a full count). Combining the ns with a second counter should be enough bits to avoid that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: