3
votes

I'm struggling to understand the difference between between preemptive and nonpreemptive kernels, and premptive & nonpreemptive scheduling.

From Operating System Concepts (Ninth Edition), Silberschatz, Galvin and Gagne:

A preemptive kernel is where the kernel allows a process to be removed and replaced while it is running in kernel mode.

A nonpreemptive kernel does not allow a process running in kernel mode to be preempted; a kernel-mode process will run until it exits kernel mode, blocks, or voluntarily yields control of the CPU.

Under nonpreemptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state. - This to me seems to be the exact same description of the nonpreemeptive kernel.

Preemptive scheduling occurs in these 2 situations (from same book):

  1. *When a process switches from the running state to the ready state (for example, when an interrupt occurs)

  2. When a process switches from the waiting state to the ready state (for example, at completion of I/O)*

The book simply states that there is a choice in this scenario, I'm not sure that the choice is. Is the choice whether the same process in the ready queue can be continued to run, or a different process from the ready queue can be selected to run?

Basically, a clear clarification on these 4 terms is what I'm looking for.

Thank you!

1
Basically, a clear clarification on these 4 terms is what I'm looking for. - There are many questions on Stack Overflow about these terms. What exactly is unclear in them? Difference between nonpreemptive scheduling and nonpreemptive kernel is that non-preemptive kernel allows preemption of the process while it is in the user mode, but nonpreemptive scheduling doesn't allow that.Tsyvarev
Get a better book. The stuff you quoted for 'Preemptive scheduling' above is a pile of misleading buzzwords tagged together:(Martin James
@MartinJames: Nah, they are not buzzwords. They are keywords and actually have a meaning. Unfortunately you are completely right about the rest.too honest for this site
@Olaf without a list of valid thread states and their meaning, (ie. an OS),. they have more buzz than key:)Martin James
@MartinJames: Meh, who needs clear definitions/specifications. We have AIs, let them handle the thinking, we're on facebook, twittering tinder to burn reason.too honest for this site

1 Answers

5
votes

The problem you face is that these terms have no standard meaning. I suspect that your book is using them from the point of view of some specific operating system (which one?—Je ne sais quois). If you have searched the internet, you have certainly found conflicting explanations.

For example, Preemptive scheduling can mean:

  1. Scheduling that will interrupt a running process that does not yield the CPU.
  2. Scheduling that will interrupt a running process before it's quantum has expired.
  3. Your book apparently has yet another definition. I cannot tell the meaning from the excerpt. It is entirely possible that book is just confusing on this point (as it apparently is on so many points). One point is that process states are system dependent. To define the term using process states is quite confusing.

This part of it definition makes sense:

Under nonpreemptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.

The preemptive part of the definition makes no sense.

In the case of the term preemptive kernel, that is pretty standard and the description of it you give is somewhat normal. That said, the book's statement should be a bit more refined because every process has to be removed in kernel mode. Normally, one would say something along the lines of "In a non-preemptive kernel, a process cannot be removed when it has entered kernel mode through an exception."

A preemptive kernel is essential for real-time processing.

So you ask:

  • This to me seems to be the exact same description of the nonpreemeptive kernel.

You have four theoretical combinations:

  1. Preemptive Scheduling Preemptive Kernel

The operating system can forcibly switch processes at nearly any time.

  1. Non-Preemptive Scheduling Preemptive Kernel

This combination does not exist.

  1. Non-Preemptive Scheduling Non-Preemptive Kernel

The process has to explicitly yield to allow the operating system to switch to another process.

  1. Preemptive Scheduling Nonpreemptive Kernel

The operating system can forcibly switch processes except when the process is executing in kernel mode to process an exception (there may be circumstances where the process cannot be switched while handling an interrupt as well).