Hardware Solutions

  1. One simple solution to the critical section problem is to prevent a process from being interrupted while executing their critical section. Unfortunately, this doesn't work well in multiprocessor environments, due to the difficulties in disabling and the re-enabling interrupts on all CPUs. There is also a question as to how this approach affects timing if the clock interrupt is disabled.
  2. Another approach is for hardware to provide certain atomic operations. Atomic instructions are those that are guaranteed to operate as a single hardware instruction, without interruption. One such operation is the "Test and Set" (see next slide,) which simultaneously (1) sets a boolean lock variable and (2) returns its previous value.
  3. Another variation on the test-and-set is an atomic swap of two booleans (see the slide after the next.)

The above examples don't guarantee bounded waiting. If several processes are trying to get into their critical sections, there is no guarantee of what order they will enter, and some process might turn to wait forever until they got their turn in the critical section. This is because, due to the relative rates of the processes, a very fast process could theoretically release the lock, speed through their remainder section, and re-lock the lock before a slower process got a chance.