select(2) timeout precision

Mihail Balikov misho at interbgc.com
Tue Nov 1 21:19:21 PST 2005


http://www.dragonflybsd.org/docs/nanosleep/

----- Original Message ----- 
From: "Viktor Vasilev" <viktor.vasilev at stud.tu-darmstadt.de>
To: <freebsd-hackers at freebsd.org>
Sent: Wednesday, November 02, 2005 12:42 AM
Subject: select(2) timeout precision


> Hello fellow hackers,
>
> I'm writing a piece of code, that basically does the following in a
> thread:
>
>   tick.tv_sec = 0;
>   tick.tv_usec = 10000;
>   gettimeofday(&t1, NULL);
>   select(0, NULL, NULL, NULL, &tick);
>   gettimeofday(&t2, NULL);
>
> With FreeBSD 5.4-RELEASE I almost constantly get ~20000 microseconds
> delta. That is with 100HZ kernel on PIII 500MHz or Sempron 64 2800+
> running in i386 mode. It also doesn't matter if I use usleep or
> select.  I've tested the code on linux with 2.6.11 kernel and there I
> not only get the 10000 us sleep, but I can also set it to 5000 us and
> it still runs very accurately.
>
> So my question is, is this a FreeBSD limitation of some kind, and is
> there a way to circumvent it?
>
>
> Best regard,
> Viktor
> -- 
> I think and think for months and years. Ninety nine times, the
> conclusion is false. The hundredth time I am right.
>                                -- Albert Einstein
>
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>



More information about the freebsd-hackers mailing list