Software mutual exclusion: Peterson's protocol
Build Peterson's two-thread protocol from two failed attempts and see which of three properties each keeps and what it assumes about memory. Synchronization and deadlock · Operating systems.
Two threads share nothing but ordinary variables. Can they still keep each other out of a critical section, and what must be true of memory for it to work?
What you will learn
- Explain why checking a flag and then raising it, or raising a flag and then waiting, each fail
- Trace Peterson's flag-and-turn protocol for two competing threads
- Name the three properties a protocol must keep and state the memory assumption behind Peterson
Lesson outline
- Look first, then raise a flag
- Raise your own flag first
- Raise, give the turn away, then look
- A thread that arrives late
- What Peterson assumes about memory
18 minutes · 4 scenes · 0 predict checks · 9 quiz questions
The full lesson is available with Premium.