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.
advance(E): Increments E, resumes waiting processes
read(E): Returns current value of E
await(E, val): Blocks until E≥val
Sequencer
Integer-valued variable (init 0) serving as a ticket server:
ticket(S): Returns current value, then increments S
Implementation
Mutual Exclusion
int S = 0; // Sequencerint E = 0; // Eventcount// Process Pimyticket = ticket(S); // Take a ticketawait(E, myticket); // Wait for turn// --- Critical Section ---advance(E); // Signal done
Deli Counter Analogy
Taking a Ticket: ticket(S) gives a unique number — like at a bakery
Watching the Display: await(E, myticket) waits until “Now Serving” reaches your number
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.