switching schedulers (Re: SCHED_ULE should not be the default)
se at freebsd.org
Fri Dec 16 10:46:36 UTC 2011
Am 16.12.2011 09:11, schrieb Luigi Rizzo:
> The interesting part is probably the definition of the methods that
> schedulers should implement (see struct _sched_interface ).
> The switch from one scheduler to another was implemented with a
> sysctl. This calls the sched_move() method of the current (i.e.
> old) scheduler, which extracts all ready processes from its own
> "queues" (however they are implemented) and reinserts them onto the
> new scheduler's "queues" using its (new) setrunqueue() method. You
> don't need to bother for blocked process as the scheduler doesn't
> know much about them.
> I am not preserving the thread's dynamic "priority" (think of
> accumulated work, affinity etc.) when switching
> schedulers, as that is expected to be an infrequent event, and
> so in the end it doesn't really matter -- at a switch, threads
> are inserted in the scheduler as newly created ones, using only
> the static priority as a parameter.
I think this is OK for user processes (which will receive reasonable
relative priorities after running a fraction of a second, anyway).
But I'm not sure whether it is possible to use static priorities for
(real-time) kernel threads, where priority inversion may occur, if the
current dynamic (relative) thread priorities are not preserved.
But not only the relative priorities of the existing processes must be
preserved, new kernel threads must be created with matching (relative)
priorities. This means, that the schedulers may be switched at any time,
but the priority values should be portable between schedulers to prevent
dead-lock (or illegal order of execution?) of threads (AFAICT).
More information about the freebsd-stable