Locks

CSC 213 - Operating Systems and Parallel Algorithms - Weinman



Figure 27.8 describes an intricate locking mechanism. Unpack it by recording your answers to the following in your Reading Journal.
  1. In your own words, briefly (1-2 complete sentences for each) explain the purpose of the flag, guard, and queue elements.
  2. In your own words, write the story in prose about what happens when a thread calls the lock function. Avoid statements like "set to zero", but instead think of the elements above as concrete objects (things or places) that require active verbs like "acquire" and actors like "the noble thread Lancelot" and "some other miscreant thread Melwas." (Ok, adjectives are optional.)
  3. Continue the story (using subjects/actors, verbs, places, and objects rather than variables and numbers) about what happens when a thread calls the unlock function.
  4. Optional: What is the moral of the story?