When a shared update races itself
Follow two threads that add to one counter, see which update is lost, and learn what a mutex must cover and what it still leaves open. Synchronization and deadlock · Operating systems.
Two threads each add 2 to a counter that holds 7, and sometimes it ends at 9 instead of 11. Where did the other 2 go, and what must be kept together to stop it?
What you will learn
- Follow a shared update step by step and find the update that is lost
- Say what a mutex must cover and who may unlock it
- Separate mutual exclusion from progress and bounded waiting
Lesson outline
- One addition is three steps
- How a result gets lost
- Keeping the three steps together
- Where the lock must start
- What a lock still leaves open
15 minutes · 4 scenes · 0 predict checks · 10 quiz questions
The full lesson is available with Premium.