|>
|> >What *I* mean by pre-emptive, is that as some process state changes, to
|> >make it higer priority that the currently running process, at *that instant*,
|> >the currently running process will be pre-empted and the higher priority
|> >process will run - this is *NOT* how "traditional" UNIX works.
|>
|> You may try a text book on operating systems for our definition of
|> pre-emptive.
|>
|> BTW, how does this magical event (not an interupt, you excluded those)
|> happen when another process is running on the CPU?
First, get a book on UNIX, not a generic OS book, they generaly talk
about things VERY diffrently from (UNIX) reality.
What you really need is a course on UNIX internals.
You can either go to AT&T, who have a selection of quite reasonable
courses, or look for suitable tutorials given either by EurOpen or USENIX.
I really don't feel like giving a complete explanation here, but I will
spend five minutes or so ...
UNIX does NOT have a kernel process, unlike many OS.
What there is, is a bunch of code which can only be run in a "protected"
environment (kernel mode).
(Actually, there *is* a process, composed entirely of kernel code, which
is managed just like any other, which shows up on ps as "system, or swapper,
or some such - on some versions of AT&T System X.y there are even two
of them, for reasons lost in the mists of time, someone once seperated
the code which moves process pages from memory to disk, from that which
moved pages from disk to memory. But even though these processes have no
user code associated, they are not treated differently).
There is NEVER more than one process running at any one time.
The currently active process is defined by (here we are talking
"traditional" UNIX, later versions, and some derivatives do things
differently) a data structure, which contains the "vital statistics"
of the current process, and points off to other kernel data structures
which contain things like memory maps.
The current process (a "user" process) will enter the kernel code
and execute it on basically one of two events, either a system call,
which an be considered to be a "soft" interrupt, or a real (hard)
interrupt from some device, or the system clock (typically running
at 60 or 100 Hz).
If you like, it is very similar to MS-DOS, except that rather than
just calling a monitor routine, you have to go via the syscall mechanisim
which enforces protection - you get a new stack etc, and there is no
way (but the "approved" way) of getting information between the two
states). You are guaranteed to enter this code because you will either
make a system call, or the clock will interrupt, or some device will.
You are then guaranteed to execute code which will relinquish the CPU
if a higher priority process exists.
It is because interrupts are serviced by a "random" process, probably NOT
the process which initiated an event, such as a disk transfer, that
device drivers under UNIX must *never* attempt to read or write data
directly into a user process.
At each "clock tick" (clock interrupt), priorities are re-calculated.
Having entered the kernel code, the process will either return to user mode,
or, if it initiated an event, such as a disk transfer, will have to wait,
and so will relinquish the processor to another process, by calling
the scheduling routines within the kernel. When this process is resumed,
it will resume in kernel mode ... In the case of a simple system call,
just before returning to user mode, the process scans the ready to run list
of processes, and if it finds one with a higher priority tha itself,
it will call the scheduling routine, which will execute code causing
a context switch (to the highest priority process).
That, is a simplified overview of how UNIX (NOTE: *U*N*I*X*) works.
Other systems do it in different ways.
So, taking the way that UNIX is traditionaly viewed, of a single executing
proccess, which runs kernel code (NOTE that on entering kernel mode, all the
same data structures are still referenced, the memory mapping (user mode)
is not changed and there was no supervisor process running, so it IS the
same process) the system can be considered non pre-emptive, since it is
the process which "voluntarily" gives up the CPU.
Some people need to get better OS books ... or maybe just read
them more carefully.
Philip
------------------
I hadn't looked at these (comp.unix) for years.
I was told by many people that they too, refrained from these groups
because the level of bad manners and plain stupidity was just too
high ... I see what they mean ...
P.