Mutual Exclusion: Software Approaches

Concurrency refers to the ability of a computer system to perform multiple tasks or processes simultaneously. It arises in three different contexts:

  1. Multiple applications
  2. Structured applications
  3. OS architecture

Concurrency can be challenging to implement correctly, as multiple threads or processes can interact with shared resources, leading to race conditions and other issues.



And so, mutual exclusion is a technique used in concurrent programming to prevent multiple threads or processes from accessing shared resources or critical sections at the same time. This could be done using software approaches, hardware approaches, or even using the OS itself.

Dekker’s Algorithm

Dijkstra reported an algorithm for mutual exclusion for two processes. As it is a software approach, we will look at code that will enforce this.

Figure 5.1 Mutual exclusion attempts.

Figure 5.1 Mutual exclusion attempts.

This solution guarantees the mutual exclusion property, but has two drawbacks.

  1. The processes must strictly alternate in their use of their critical section.
  2. If one process fails, the other process is permanently blocked.

It goes through a few attempts before achieving the correct solution, that is Dekker’s algorithm.

Figure 5.2 Dekker’s algorithm.

Figure 5.2 Dekker’s algorithm.