Subject: Re: Is the netBSD kernel Preemptible ?
To: None <tech-smp@netbsd.org>
From: Matthias Scheler <tron@zhadum.de>
List: tech-smp
Date: 06/19/2002 11:40:43
In article <20020614182820.93389AC@proven.weird.com>,
	woods@weird.com (Greg A. Woods) writes:
>> The SVR4 kernel was changed to allow preemption in the kernel
>> at the same time as it was made SMP.
> 
> So, how exactly does an application level process go about the task of
> preempting the kernel?

It simply gets scheduled. In SunOS 5.x which is a SVR with a preemptable
SMP kernel the kernel runs threads. There are kernel only threads (e.g.
the page daemon) and threads with an user process attached to them.
If an user process performs a system call its thread simply enters the
kernel but remains a normal thread which can be preempted. On a Solaris
kernel where the RealTime scheduler class is loaded the priorities
looks somethings like this:

151-160	high level interrupts
101-150	RealTime user threads
 61-100 normal kernel threads
 0 - 60 normal user threads

[I'm not 100% about the absolute numbers but they are not important.]

As a result kernel threads can preempt each other and users threads
can preempt kernel threads if they have a high priority. This requires
fine grained locking of course.

	Kind regards

-- 
Matthias Scheler                                  http://scheler.de/~matthias/