Re: Fully and Partially pre-emptible kernel

From: Jonathan Adams (jwadams_at_gmail.com)
Date: 08/24/04


Date: 24 Aug 2004 05:07:41 -0700

prakash.prabhu@gmail.com (Prakash Prabhu) wrote in message news:<85a4cc05.0408230936.36ec0fc6@posting.google.com>...
> > However, unless there are enough CPU's to
> > run processes A and B, then it's certainly possible process A will be
> > descheduled and process B will be scheduled.
>
> I am slightly confused about how exactly can process A be descheduled and process
> B be scheduled when here the scheduler itself is to be pre-empted ?
> What is that part of the kernel that will pre-empt the scheduler and again
> re-invoke it ( to schedule process B ) ?

There's some confusion here, partially due to some odd bits of Solaris
parlance. The "scheduler", known as PID 0, process "sched", only
handles swapping whole processes to and from disk. The subsystem
which handles picking which processes to run, preempting running
threads, etc. is known as the "dispatcher". Note that there is no
seperate "dispatcher" thread -- all the dispatcher work happens on an
"as needed" basis by all the threads in the system.

Threads which are in the dispatcher code cannot be preempted -- it all
runs at high PIL (DISP_LEVEL, or 11), which is above LOCK_LEVEL (10),
which means that the thread block or be preempted. It *can* be
interrupted by high-level interrupts (for example, by the timer
interrupt, which runs at PIL 14), but those don't change the
progression.

Jim Mauro's "Inside Solaris" articles (later pulled together and
expanded into the "Solaris Kernel Internals" book, which is
recommended reading) on the dispatcher are still reasonably accurate,
even though it only talks about releases up to Solaris 7:

http://sunsite.uakom.sk/sunworldonline/swol-01-1999/swol-01-insidesolaris.html
http://sunsite.uakom.sk/sunworldonline/swol-02-1999/swol-02-insidesolaris.html

(The details have gotten a bit more complicated in later releases, but
the broad sweep is the same)

- jonathan



Relevant Pages

  • Re: pthread and multiple CPU
    ... First question is: ... does it guarantee that each CPU has one thread? ... because the Solaris scheduler will ... Don't try to prevent the O/S' scheduler ...
    (comp.programming.threads)
  • thread/process & memory management source code
    ... where the code for FreeBSD's thread/process & memory management are? ... Specifically, where the dispatcher and scheduler is implemented, ... where the dynamic storage allocation algorithm is implemented(I'll try ...
    (freebsd-arch)
  • thread/process & memory management source code
    ... where the code for FreeBSD's thread/process & memory management are? ... Specifically, where the dispatcher and scheduler is implemented, ... where the dynamic storage allocation algorithm is implemented(I'll try ...
    (freebsd-hackers)
  • Cant delete printer
    ... scheduler is not running ... system default destination: t4377 ... However I have no prnters currently defined on my Solaris 9 box. ...
    (SunManagers)
  • Re: Question: Scheduler Exit or modularization of scheduler?
    ... Solaris's SunOS SVR4.x has a modular schedular / dispatcher, ... changes to support this new task class by the end of Aug. ... Could it be possible to design the interface to the scheduler ...
    (Linux-Kernel)