Mutual Exclusion - aryanjoshi0823/5143-Operating-System GitHub Wiki

What is Mutual Exclusion?

Mutual Exclusion is a property of process synchronization that ensures:
“No two processes can exist in the critical section at any given point in time.”

Mutual exclusion ensures that when a process (e.g., P1) accesses a shared resource (e.g., R1), no other process can access it until P1 completes its task.

Requirements for Mutual Exclusion:

  1. Only one process is allowed in the critical section at a time.
  2. Solutions are implemented entirely in software.
  3. A process spends a bounded time in its critical section.
  4. The solution works for asynchronous processes without relying on their relative speeds.
  5. A process cannot indefinitely block others from accessing the critical section.
  6. No process should wait indefinitely to enter the critical section.

Example:

Consider a shared linked list where processes manipulate nodes:

  • If two threads simultaneously remove two nodes, inconsistencies arise as pointers are improperly updated.
  • Mutual exclusion prevents this by ensuring only one thread modifies the structure at a time.