Subject: Re: [linux-audio-dev] sched_setscheduler question ...
From: John Lazzaro (lazzaro_AT_CS.Berkeley.EDU)
Date: Sun Jun 11 2000 - 00:44:20 EEST
I think I may have a good technique in answer to this question
I posted to the list yesterday:
> 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?
This function seems to fit the bill:
void let_SCHED_OTHER_run(void)
{
/* adapted from code by Gordon W. Ross */
struct timespec sleep_time;
sigset_t blocked_wake;
sigemptyset(&blocked_wake);
sleep_time.tv_sec = 0;
sleep_time.tv_nsec = 1;
sigtimedwait(&blocked_wake, NULL, &sleep_time);
}
At least from a Linux-centric perspective -- a look at
the Linux sources for sigtimedwait() (in kernel/signal.c)
seems to indicate that it always suspends at least once,
and it doesn't busywait for delays < 10ms. Its unclear
how much of this semantics is POSIX-guaranteed, though --
and incidently, if one can believe Solaris man pages,
one of the behaviors sigtimedwait() is supposed to have
under POSIX (return immediately with an error condition
if sleep_time == 0 and no signal is pending) Linux
currently doesn't do, it behaves identically for 0 nsec
and 1 nsec in the code above.
--jl
-------------------------------------------------------------------------
John Lazzaro -- Research Specialist -- CS Division -- EECS -- UC Berkeley
lazzaro [at] cs [dot] berkeley [dot] edu www.cs.berkeley.edu/~lazzaro
-------------------------------------------------------------------------
This archive was generated by hypermail 2b28 : Sun Jun 11 2000 - 01:26:22 EEST