Re: Short sleep precision

2005-03-22 Thread Jan Engelhardt
>> That's looks like a lot of CPU consumption, which I would like to avoid >> because time_to_sleep is nondeterministic in my case. > > If you want to delay for less than a tick, you pretty much need to busy-wait. > There's no way to set a timer for intervals less than a tick in the regular > kerne

Re: Short sleep precision

2005-03-21 Thread Jan Engelhardt
Hello, >> > You can spin on the gettimeofday() result in userspace. >> How can I use it? > Something like: > > gettimeofday(&curtime,0); > add_usecs(&curtime, time_to_sleep); > do { > gettimeofday(&curtime,0); > } while (time_before(&curtime, &expiry); That's looks like a lot of CPU consum

RE: Short sleep precision

2005-03-21 Thread Robert White
Actually look at linux/Documentation/rtc.txt for a "reasonably portable" way to get very small quanta with fair regularity. Since the original poster wanted it to be user accessible, and since it is a contended/exclusive device, he may want to make a broker daemon or something. Since nanosleep d

Re: Short sleep precision

2005-03-21 Thread Chris Friesen
Jan Engelhardt wrote: You can spin on the gettimeofday() result in userspace. How can I use it? Something like: gettimeofday(&curtime,0); add_usecs(&curtime, time_to_sleep); do { gettimeofday(&curtime,0); } while (time_before(&curtime, &expiry); Of course, if someone changes the system ti

Re: Short sleep precision

2005-03-20 Thread Jan Engelhardt
>Running your program here I see even worse values than that on 2.6.11-mm4 >and it's also interresting to see that for a lot of continuous runs the >values reported drop steadily and eventually settle around ~1100, but if I >insert a sleep 1 between runs, then I see a steady ~1000 reported. >T

Re: Short sleep precision

2005-03-20 Thread Andrew Morton
Jan Engelhardt <[EMAIL PROTECTED]> wrote: > > I have found that FreeBSD has a very good precision of small sleeps -- Linux nanosleep() used to have a busywait loop for sleeps less than two milliseconds. 2.4.x still does. We thought it was stupid and took it out. > what's holding Linux back fro

Re: Short sleep precision

2005-03-20 Thread Jesper Juhl
On Sun, 20 Mar 2005, Jan Engelhardt wrote: > Hello, > > > I have found that FreeBSD has a very good precision of small sleeps -- > what's holding Linux back from doing the same? Using the code snippet below, > FBSD yields between 2 and 80 us on the average while Linux is at > "constantly" ~100

Short sleep precision

2005-03-20 Thread Jan Engelhardt
Hello, I have found that FreeBSD has a very good precision of small sleeps -- what's holding Linux back from doing the same? Using the code snippet below, FBSD yields between 2 and 80 us on the average while Linux is at "constantly" ~100 (with HZ=1000) and ~1000 (HZ=100). Jan Engelhardt --