Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is preemption / What is a preemtible kernel? What is it good for?

Explained in your own words, what is preemption and what does it mean to a (linux) kernel?

What are advantages and disadvantages in having a preemptible kernel?

like image 612
Markus Avatar asked May 03 '09 13:05

Markus


People also ask

What is user preemption and kernel preemption?

The various preemption models are kernel specific. In principle, user space programs are always preemptible. Preemption of a running task is performed by the scheduler. This action can be triggered by a kernel interaction like a system call or an asynchronous event like an interrupt.

What are the advantages of preemptive kernels over non preemptive kernels?

In brief, the main difference between preemptive and nonpreemptive kernel is that the preemptive kernel allows a process in execution in the kernel mode to be interrupted by some other process while a nonpreemptive kernel does not allow that to happen. Also, nonpreemptive kernels are easier to design.

What is preemption Linux?

preemptive means when a new process is ready to run, the cpu will be allocated to the new process, it doesn't need the running process be co-operative and give up the cpu.

Which is preemptive scheduling kernel?

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.


1 Answers

Preemptive multitasking - Running several processes/threads on a single processor, creating the illusion that they run concurrently when actually each is allocated small multiplexed time slices to run in. A process is "preempted" when it is scheduled out of execution and waits for the next time slice to run in.

A preemptive kernel is one that can be interrupted in the middle of executing code - for instance in response for a system call - to do other things and run other threads, possibly those that are not in the kernel.

The main advantage of a preemptive kernel is that sys-calls do not block the entire system. If a sys-call takes a long time to finish then it doesn't mean the kernel can't do anything else in this time. The main disadvantage is that this introduces more complexity to the kernel code, having to handle more end-cases, perform more fine grained locking or use lock-less structures and algorithms.

like image 113
shoosh Avatar answered Sep 20 '22 13:09

shoosh