Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean to say "linux kernel is preemptive"?

I read that Linux kernel is preemptive, which is different from most Unix kernels. So, what does it really mean for a kernal to be preemptive?

Some analogies or examples would be better than pure theoretical explanation.

ADD 1 -- 11:00 AM 12/7/2018

Preemptive is just one paradigm of multi-tasking. There are others like Cooperative Multi-tasking. A better understanding can be achieved by comparing them.

like image 980
smwikipedia Avatar asked Mar 12 '11 15:03

smwikipedia


People also ask

What does it mean for a kernel to be preemptive?

Preemptive Kernel, as name suggests, is a type of kernel that always executes the highest priority task that are ready to run. It cannot use-non-reentrant functions unless and until functions are mutual exclusive.

Is Linux kernel preemptive or non preemptive?

The Linux kernel, unlike most other Unix variants and many other operating systems, is a fully preemptive kernel. In non-preemptive kernels, kernel code runs until completion. That is, the scheduler is not capable of rescheduling a task while it is in the kernel—kernel code is scheduled cooperatively, not preemptively.

Is Linux scheduling preemptive?

All scheduling is preemptive: If a process with a higher static priority gets ready to run, the current process will be preempted and returned to its wait list. The scheduling policy only determines the ordering within the list of runnable processes with equal static priority. There is a single run-queue.

Is Linux preemptive multitasking?

Linux, like all Unix variants and most modern operating systems, provides preemptive multitasking. In preemptive multitasking, the scheduler decides when a process is to cease running and a new process is to resume running. The act of involuntarily suspending a running process is called preemption.


1 Answers

Prior to Linux kernel version 2.5.4, Linux Kernel was not preemptive which means a process running in kernel mode cannot be moved out of processor until it itself leaves the processor or it starts waiting for some input output operation to get complete.

Generally a process in user mode can enter into kernel mode using system calls. Previously when the kernel was non-preemptive, a lower priority process could priority invert a higher priority process by denying it access to the processor by repeatedly calling system calls and remaining in the kernel mode. Even if the lower priority process' timeslice expired, it would continue running until it completed its work in the kernel or voluntarily relinquished control. If the higher priority process waiting to run is a text editor in which the user is typing or an MP3 player ready to refill its audio buffer, the result is poor interactive performance. This way non-preemptive kernel was a major drawback at that time.

like image 71
pradeepchhetri Avatar answered Oct 02 '22 07:10

pradeepchhetri