Synchronization
  • Introduction
  • Race Condition
    • Too Much Milk Problem
  • Mutual Exclusion
    • Shared Output
  • Semaphore in C
  • Too Much Milk: Use semaphore
  • Shared Output: Use semaphore
  • Traffic Control Problem
  • Traffic Control: Solution
  • Shared Memory
Powered by GitBook
On this page

Was this helpful?

Mutual Exclusion

Before we look into the solution, let's define some terminology.

  • Mutual exclusion prevents multiple threads from accessing the same shared resource at the same time.

  • The critical section is the code that only one thread can execute at a time.

  • A lock is a mechanism to realize mutual exclusion.

PreviousToo Much Milk ProblemNextShared Output

Last updated 1 month ago

Was this helpful?