How and why to implement a critical section?

Why: to prevent race conditions.

  1. Two or more processes accessing the same memory loc AND
  2. At least one of the processes is writing to it.

Properties needed:

  1. Mutual Exclusion
  2. Progress
  3. No starvation

Peterson’s algorithm

Lamport’s bakery algorithm