On Friday 31 October 2003 10:01, Iftach Hyams wrote: > >> Hi, > >> I have a question regarding short sleeps (under 10 millisec). > > 1. Busy wait : It is like the story about Abed (in "Yalkut Hakzavim") > - Abed could throw a grenade to 80 meters. Once he needed to throw to > 50 meters he stepped back 30 ... > > 2. You can't do idle wait less then 10mSec. The clock in PC is set to > that value > (probably can be manipulate, but it will result so many things so > better not).
There is no problem whatsoever to set the clock to other speeds. , it's jsut a #define in the kernel sources (look for HZ) In kernel 2.6.x this #define is configurable via the regular "make *config" facility. For 2.4.x there's a patch that accomplish the same and I've used it for several projects with not problem. For 2.2 you can just change the value of the HZ define yourself. A value of 1024 is recomended. The 2.4 patch/2.6. feature is discussed by it's author Robert Love here: http://kerneltrap.org/node/view/464/1466 The patch also turns jiffies to a 64 bit variable to avoid the problem of jiffie warp around that might bite you with high HZA values otherwise. With this patch, nanosleep (and even usleep) will give you what you want. *IMPORTANT* If timing is important to you as it seems it does, make sure to use sched_setscheduler() and sched_setpriority() to give real time priority to the proccess that requires these short sleeps, otherwise NONE of the methods suggested above (by me or other people) is guranteed to work. In fact, it's guranteed not to work :-) You owe the Linux real time oracle a jiffie. Cheers, Gilad -- Gilad Ben-Yossef <[EMAIL PROTECTED]> http://benyossef.com ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
