Disabling Interrupts

Disabling Interrupts

Disabling interrupts is the approach XINU uses. Here, once a process is executing inside the kernel, interrupts are disabled. This effectively prevents context switches, which prevents another process from manipulating the same data structure concurrently (or in an interleaved way) with the first process.

If you think about it, you'll realize that there are only two things that can initiate a context switch.

There is nothing else that can cause a context switch. By disabling interrupts, we prevent the first cause of context switches. It is still possible that the running process can itself cause a context switch.

Because of this, when writing kernel code, great care must be taken to ensure that no calls are made that could cause a context switch to happen in a sensitive part of the code (for example, half way through a linked-list manipulation). This requires that the O/S implementor know enough about the rest of the O/S implementation to avoid these calls at inopportune times.

So, between disabling interrupts and careful kernel code writing, we can ensure that our O/S data structure manipulation routines are protected from race conditions.

1