On Friday 31 August 2001 09:44, Jens Michaelsen wrote:
> Does one of the books describe how to udelay a thread?

Probably not, as it's not really possible to do in a nice way. Busy 
waiting would work for very short delays, and sometimes for experimental 
use, but you must be aware that:

        * if you're doing it in a normal thread, the kernel will
          eventually get fed up with your CPU hogging and stealing
          the CPU for extended amouts of time, and that

        * if you're doing it in a SCHED_FIFO thread, the entire
          system (well, actually only user space) will freeze
          totally until you willingly give the CPU away.


> Tryed usleep() for non-rt which ends up with milli seconds :(

Yes, the granularity depends on "HZ", which is normally 100 (10 ms) on 
x86. You can change it to say, 1000 Hz if you like, but IIRC, you may 
need to recompile some (old?) user space tools if your system relies on 
their correct operation. (The use the HZ define from the kernel headers.)

If you don't want to fiddle with a custom kernel, you can use either an 
RTL kernel driver + blocking on an RTL FIFO, or the standard Linux RTC 
driver.

Actually, any driver that can wake sleepers up as a result of a hardware 
IRQ (ie most drivers) may be useful. Unless the kernel is busy, it 
reschedules directly after processing interrupt handlers - that's how you 
can perform unbuffered I/O in small blocks without relying on HZ periods 
to wake up after blocking.


> Once there was a extension to linux that should support udelays.
> Where is it gone??

Isn't that the "utime patch"...? IIRC, it fiddles with the timer to 
produce interrupts at the requested wake-up times, rather than relying on 
the fixed HZ IRQ rate. Not too functionally different from the RTL 
scheduler, that is. (Although we're still talking about user space with 
the usual scheduling latencies.)


//David Olofson --- Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
|      Multimedia Application Integration Architecture      |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------------> http://www.linuxdj.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`--------------------------------------> [EMAIL PROTECTED] -'

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to