Low-level mutual exclusion primitives

There are several ways that the operating system may achieve mutual exclusion of its critical regions within processes. For one reason or another, though, none of the following mechanisms are generally suitable for use in user-level code.

The first two are 'hardware' solutions; the second two are 'software' solutions:

  1. Disabling interrupts - suspend multitasking: no more race conditions.
  2. Lock variables and the Test & Set instruction - with a little help from the CPU.
  3. Alternation - taking turns.
  4. Peterson's solution - a good solution in software.

summary

All the techniques described above are rather antisocial to other processes: the last three depend on busywaiting in order to work; the first switches off task-switching. This makes them impractical when the critical sections are large.

In practice, the above techniques are used within the kernel for...


last updated 13 February 1998