[ale] Scheduling questions
Michael D. Hirsch
mhirsch at nubridges.com
Tue Nov 25 09:09:16 EST 2003
On Monday 24 November 2003 10:37 pm, Bjorn Dittmer-Roche wrote:
> Hey all,
>
> I have volunteered to write some stuff about acheiving low latency
> on Unix (like) OSes for an audio list I'm on. It's coming along OK but
> here are two issues that I'm having particular trouble with:
>
> * Here is what I say about general purpose timesharing:
>
> --------------------------------
>
> Without any special attention, Unix scheduling uses a default time-sharing
> scheduler that works somthing like this: each process is given a "nice
> value" and an initial priority. If a process uses lots of CPU time, it's
> priority is reduced, otherwise it might be increased, but never above the
> "nice value". At any given time, the Kernel selects the runnable process
> with the highest priority to run. If several processes are runnable and
> all have the same priority, it may split the time between them in some way
> or it may just run one of them until it is no longer runnable.
> --------------------------------
>
> Of course this varies from system to system so I'm just trying to give
> people an idea. Is it more or less correct?
I don't know how technical you want to get. The writeup above makes it sound
like a low priority task will never run if there is a higher priority task
waiting, and I think that is not the case. I think that every process gets a
timeslice, and higher priority tasks get either bigger, or more timeslices.
But in essence what you say is correct.
> * The other question is this: does POSIX define the relationship between
> pthread scheduling and process scheduling? That is, if I have a processess
> with a given priority and threads that all have their own priorities, will
> each thread be scheduled by the OS or will they be "sub-scheduled" within
> the process. More important than POSIX: do implementations generally agree
> one way or the other? I've done some googling, but I haven't seen this
> issue addressed (except for particular OSes), so maybe someone knows a
> good link? My impression is that Posix specifies subscheduling but that
> some implementations extend this. seem right?
I don't think POSIX specifies. Certainly there are thread implementations of
each way, and I never heard an objection that one way or another violates
POSIX. Solaris has both types at once, in fact. Linux only has threads that
are scheduled like processes. True, linux threads aren't quite POSIX (until
recently), but that was due to signal processing, not scheduling.
Michael
More information about the Ale
mailing list