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)?
Asked
Active
Viewed 715 times
2
-
The scheduler is not a kernel task (but it manages these preemptable tasks) – Basile Starynkevitch Jan 19 '15 at 06:17
-
So what is the scheduler? A userspace program if not kernel task? – WindChaser Jan 19 '15 at 16:28
-
The scheduler is an essential part of the kernel, but it is not a kernel task – Basile Starynkevitch Jan 19 '15 at 17:49
-
Could you tell me the difference? Thanks. – WindChaser Jan 19 '15 at 18:23
-
You should take several hours to read some material about operating system & kernel. – Basile Starynkevitch Jan 19 '15 at 18:40
-
I cannot find the concept "kernel task" when searching several Linux kernel books (using string matching)... – WindChaser Jan 19 '15 at 19:54
2 Answers
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