Re: [linux-audio-dev] sched_setscheduler question ...

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] sched_setscheduler question ...
From: Paul Barton-Davis (pbd_AT_Op.Net)
Date: Sat Jun 10 2000 - 01:34:35 EEST


> If there's only one process running on SCHED_FIFO,
>and the process wants to let the SCHED_OTHER processes have
>a chance at running, what's the best way to do this?
>Experimentally, calling usleep() with a value > 10ms does
>it in practice (I assume this is > 1/HZ), but it does enforce
>a minimum time delay -- is there a way to get "let SCHED_OTHER
>processes that want to run run, then get back to me ASAP"
>behavior?

No, there is no POSIXLY_CORRECT way to do this. The semantics of a
SCHED_FIFO task are that if it is runnable, then it runs. Unless you
do something to make it unrunnable (like usleep()), it will be on the
processor.

[ BTW, I take it you've looked at the kernel source for usleep() - the
reason for the 10ms minimum is that usleep was written to allow
SCHED_FIFO tasks to do precise timing with usleep(), so if the period
is less than 10ms, it busy-waits rather than yielding the processor. ]

However, I cannot understand why you want sfront to run SCHED_FIFO. My
understanding of sfront (and I've read most of the manual
cover-to-cover) is that its a non-realtime application. If you just
want to get more CPU time, just increase the regular SCHED_OTHER
priority. Other SCHED_OTHER tasks will still get to run, based on the
normal timeslice, but sfront will gets lots of CPU time.

SCHED_FIFO is strictly designed for soft real-time applications.

One bizarre thing that you could do is to open an audio device, and
sleep on the I/O to/from the card. This would give you a real sleep
time of way less than 10ms. It seems bizarre, however, since sfront
doesn't emit any audio. A better alternative would be to open the RTC
and sleep on that every so often. You could set it up for any interval
you wanted (power-of-2 HZ interrupts) - ah, hell, this won't work
because the RTC stops working if you don't handle interrupts. Well, I
don't know how slow it would be, but you could open it, set it up,
sleep on it, then close it again.

--p


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sat Jun 10 2000 - 02:09:01 EEST