Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the exact definition of 'process preemption'?

Wikipedia says:

In computing, preemption is the act of temporarily interrupting a task being carried out by a computer system, without requiring its cooperation, and with the intention of resuming the task at a later time.

Other sources say:

[...] preemption means forcefully taking away of the processor from one process and allocating it to another process. [Operating Systems (Self Edition 1.1), Sibsankar Haldar]

Preemption of a program occurs when an interrupt arises during its execution and the scheduler selects some other programs for execution. [Operating Systems: a Concept-based Approach, 2E, D. M. Dhamdhere]

So, what I understood is that we have process preemption if the process is interrupted (by a hardware interrupt, i.e. I/O interrupt or timer interrupt) and the scheduler, invoked after handling the interrupt, selects another process to run (according to the CPU scheduling algorithm). If the scheduler selects the interrupted process we have no process preemption (interrupts do not necessarily cause preemption).

But I found many other sources that define preemption in the following way:

Preemption is the forced deallocation of the CPU from a program. [Operating Systems: a Concept-based Approach, 2E, D. M. Dhamdhere]

You can see that the same book reports two different definitions of preemption. In the latter it is not mentioned that the CPU must be allocated to another process. According to this definition, preemption is just another name for 'interruption'. When a hardware interrupt arises, the process is interrupted (it switches from "Running" to "Ready" state) or preempted.

So my question is: which of the two definitions is correct? I'm quite confused.

like image 224
LordFenerSSJ Avatar asked Apr 30 '16 20:04

LordFenerSSJ


People also ask

What is meant by process preemption?

When a higher priority process becomes dispatchable, the kernel interrupts its computation and forces the context switch, preempting the currently running process. A process can be preempted at any time if the kernel finds that a higher-priority process is now dispatchable.

What is preemption in real time system?

Preemption is the process in which a running thread is stopped so that another process can run. This can be the result of an interrupt, or an action of the running thread itself. In preemptive scheduling, the RTOS always runs the highest-priority thread that is READY to run.

What is preemption What are the advantages of it?

Advantages of Preemptive Scheduling Preemptive scheduling method is more robust, approach so one process cannot monopolize the CPU. Choice of running task reconsidered after each interruption. Each event cause interruption of running tasks. The OS makes sure that CPU usage is the same by all running process.

What is resource preemption?

To eliminate deadlocks using resource preemption, we successively preempt some resources from processes and give these resources to other processes until the deadlock cycle is broken. In some cases it may be possible to temporarily take a resource away from its current owner and give it to another process.


1 Answers

The Wikipedia definition is pretty bad.The others are not so good. However, they are all saying essentially the same think.

Preemption is simply one of the means by which the operating system changes the process executing on a CPU.

Such a change can occur either through by the executing process voluntarily yielding the CPU or by the operating system preempting the executing process.

The mechanism for switching processes (context switch) is identical in both methods. The only difference is how the context switch is triggered.

A process can voluntarily yield the CPU when it no longer can execute. E.g. after doing I/O to disk (which will take a long time to complete). Some systems only support voluntary yielding (cooperative multitasking).

If a process is compute-bound, it would hog the CPU, no allowing other processes to execute. Most operating systems use a timer interrupt. If the interrupt handler finds that the current process has executed for at least a specified period of time and there are other processes that can execute the OS will switch processes.

Preemption is then a process (or thread) [context] switch on a CPU that is triggered by the operating system rather than by the process (or thread) itself.

like image 115
user3344003 Avatar answered Nov 11 '22 01:11

user3344003