2

Can the scheduler or some critical kernel threads be preempted in a preemptible Linux kernel? What about in an interrupt handler (top half or bottom half)?

WindChaser
  • 960
  • 1
  • 10
  • 30

2 Answers2

1

The kernel calls __schedule() to do the actual context switch. It always call this with preemption disabled. You can search the callers and notice the call to preempt_disable before calling __schedule. So, it can't be preempted.

Also, an interrupt handler cannot be preempted. Preemption is disabled here. But linux kernel is preemptible which means kernel threads and other code can be preempted if it is safe.

bornfree
  • 2,308
  • 1
  • 23
  • 33
0

Any kernel thread or generally speaking any portion of code can be preempted :

  • By a thread of higher priority
  • While not in a section protected against interrupts and preemption

So yes even the scheduler can be preempted by a hardware interrupt for instance.

MSI
  • 844
  • 9
  • 8