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:
- Only one process is allowed in the critical section at a time.
- Solutions are implemented entirely in software.
- A process spends a bounded time in its critical section.
- The solution works for asynchronous processes without relying on their relative speeds.
- A process cannot indefinitely block others from accessing the critical section.
- 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.