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

  1. Look first, then raise a flag
  2. Raise your own flag first
  3. Raise, give the turn away, then look
  4. A thread that arrives late
  5. What Peterson assumes about memory

18 minutes · 4 scenes · 0 predict checks · 9 quiz questions

The full lesson is available with Premium.