1

Is the Linux kernel preemptive or not?

There is a big difference between Understanding the Linux Kernel 2nd edition and 3rd edition. In the 2nd it is written that the Linux kernel is not preemptive but in the 3rd in the same paragraph nothing is said.

osgx
  • 90,338
  • 53
  • 357
  • 513
likeIT
  • 297
  • 5
  • 10

2 Answers2

4

Yes, the kernel is preemptive.

It has been preemptive by default since the 2.6 branch. Of course, its preemption has not always been perfect, as the techniques for balancing preemption with process responsiveness depend heavily on the kernel load profile (which isn't the same for everyone).

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
1

Depends on the kernel version.

The 2.6 set is supposed to be.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • Doesn't every modern multipurpose operating system have preemptive multitasking? – sjr Apr 22 '11 at 19:32
  • @sjr There's 2 sides to that, with pretty much all general purpose operating systems, a process can be preempted. However not all OS's allow you to preemt a process _while it is executing kernel code_. – nos Apr 22 '11 at 19:36
  • @nos, while what you say is true, even the Linux kernel blocks itself from being swapped off the CPU in certain situations, like the front-end handlers of hardware interrupts. Hard to blame a monolithic kernel for not preempting during a system call when the kernel itself cannot be swapped for "certain" operations. – Edwin Buck Apr 22 '11 at 19:42
  • Yes, there's many places you cannot preempt anything. However, the way linux (and many *nixes) used to be, was that once did a syscall, once you entered the kernel, you could not be preemted no matter what - with 2.6 this is no longer the case, you can for the most part preempt - but not in all cases - a process while it's executing kernel code. – nos Apr 22 '11 at 19:59