Questions about preemption and concurrency

Daniel Baluta daniel.baluta at gmail.com
Fri May 27 09:21:34 EDT 2011


On Fri, May 27, 2011 at 2:44 PM, Naman shekhar Mishra
<namanshekharmishra2 at yahoo.in> wrote:
> In Operating System Concepts 6th ed, chapter 20:
> "Kernel code can thus assume that it will never be preempted by another
> process and that no special care must be
> taken to protect critical sections. The only requirement is that critical
> sections do not contain references to user memory
> or waits for I/O completions"

This is available only if the kernel is non-preemptive. If the kernel is
preemptive than a process executing in kernel, can be preempted
by another process.


> Why us that the process cannot wait for I/O to complete in critical
> sections?

Because deadlocks may sneak in ([1]).

> My another question is: While developing kernel modules (for kernels before
> 2.6), do we need to keep concurrency in mind?

I guess yes. Even if the kernel is non-preemptive, you may want to consider SMP.

> Because the modules run as part of the kernel and no two processes can run
> in the kernel at the same time? Or my question is wrong since they CAN run
> in the kernel at the same time (like when one process waits for I/O
> completion and another is scheduled to run which then makes a system call)?
>
> Please excuse me for the multiple nested question since I didn't quite know
> how to put it.

HTH,
Daniel.

[1] https://lwn.net/Articles/274695/



More information about the Kernelnewbies mailing list