operating-systems concurrency

Definition

Sequencer and Eventcount

Sequencer and eventcount are synchronisation primitives for ordering events and waiting for completion. Used together to implement mutual exclusion and bounded waiting without semaphore complexity.

Primitives

Eventcount

Integer-valued variable (init 0) tracking event occurrences:

  • advance(E): Increments , resumes waiting processes
  • read(E): Returns current value of
  • await(E, val): Blocks until

Sequencer

Integer-valued variable (init 0) serving as a ticket server:

  • ticket(S): Returns current value, then increments

Implementation

Mutual Exclusion

int S = 0;  // Sequencer
int E = 0;  // Eventcount
 
// Process Pi
myticket = ticket(S);   // Take a ticket
await(E, myticket);     // Wait for turn
// --- Critical Section ---
advance(E);             // Signal done

Deli Counter Analogy

  1. Taking a Ticket: ticket(S) gives a unique number — like at a bakery
  2. Watching the Display: await(E, myticket) waits until “Now Serving” reaches your number
  3. Updating the Display: advance(E) increments the counter, allowing the next ticket holder to proceed

Each ticket is unique and served in order, ensuring FIFO mutual exclusion.

Benefits

Fairness

Naturally enforces FIFO ordering.

Simplicity

No explicit queue management needed — await handles blocking automatically.