How to use sem_timedwait?
Goran Mekić
meka at tilda.center
Wed Dec 14 09:51:52 UTC 2016
On Wed, Dec 14, 2016 at 11:24:37AM +0200, Konstantin Belousov wrote:
> Because this is how computers work. The declared resolution is the
> resolution of the clock_gettime(2) call. While you tried to measure the
> different actions: de-facto you scheduled a wakeup, then put the thread
> to sleep, then thread was awaken. The system guarantees that the thread
> is made runnable due to timeout not earlier than the interval specified.
> After the thread is marked runnable, it should be selected for CPU, then
> the syscall must complete which put thread to sleep, then userspace must
> execute enough to call clock_gettime(), then it should return etc.
>
> You end up with 1.7ms difference between requested and actual wakeups in
> this attempt, which is quite good.
>
> Note that system also does some micro-optimizations by trying to collapse
> wakeups close enough to each other, which might also affect occurences
> of wakeups.
OK, that sounds logical, but I have a problem now. I need < 1ms precision on this. Is there a way to achieve it? Anyway, thanks for the clarification!
Regards,
meka
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20161214/7b0a5ee2/attachment.sig>
More information about the freebsd-hackers
mailing list