Synchronisation, critical sections and semaphores
45 min · Intermediate
Synchronisation is controlling the order in which concurrent processes or threads touch shared data, so the result is always correct. Without it, two people booking the last train seat at the same moment can both get a confirmation.
Topics in this lesson
- Race condition example and the critical-section problem
- Mutual exclusion, progress and bounded waiting
- Mutex vs binary vs counting semaphore
- Producer-consumer and readers-writers at a high level
- Interview questions with model answers
Interview questions this lesson answers
- What is process synchronisation?
- What is a race condition?
- Why is
count++not atomic? - What is a critical section?
- What are the entry, exit and remainder sections?
- What are the three requirements for a solution to the critical-section problem?
- What is Peterson's solution?
- What hardware support exists for synchronisation?
- What is compare-and-swap?
- What is a semaphore?
Sign in free to continue this lesson
Create a free account to read every lesson, practise with the exercises and keep track of your progress.