Bus arbitration 2026-10-13
Selecting among initiators requesting a shared resource. An arbiter grants permission before an initiator starts its bus transaction. Fixed priority can indefinitely postpone a lower-priority requester under continuing higher-priority demand. Rotating priority can provide starvation freedom when every owner releases the resource after bounded work. Neither policy alone determines bus throughput: waiting, setup and target readiness also matter.[ref]
Lecture 21: Buses and I and O. CS152 lecture 21, slides 35–36: reservation, priority and fairness
Deadlock freedom 2026-10-14
Absence of a reachable deadlock. In the finite acquisition model under deadlock, reaching a nonterminal state with no enabled operation is a finite witness to failure, so this formulation is a safety property. Sometimes the phrase is used for eventual acquisition by some requester, a liveness property; the intended requirement must be stated. Neither formulation by itself promises starvation freedom for every requester.
Liveness property 2026-10-14
A requirement of eventual progress, with no finite prefix ruling out its eventual satisfaction. For starvation freedom, a persistent requester must eventually enter its critical section. Establishing such a liveness property requires explicit scheduling and protocol assumptions in addition to mutual exclusion. Exhaustive finite thread interleaving checks alone do not establish eventual service for repeatedly competing software threads.[ref]
Defining Liveness by Bowen Alpern and others. p. 182: every finite prefix can still be extended to satisfy a liveness property
Message-passing mutual exclusion server 2026-10-25
Maintain an owner identity, initially empty, and a FIFO queue of accepted client requests. A request appends its sender to the FIFO queue. A release from the owner clears the owner. Whenever there is no owner and the FIFO queue is nonempty, remove its oldest request, record that client as owner, and send a grant. The server processes these state changes sequentially.
Safety proof. At most one grant is outstanding: a new grant requires an empty owner field, and a valid release clears precisely the preceding ownership. Compliant clients access the resource only while holding their grant, so mutual exclusion follows. With reliable eventual message passing, continued server execution and finite resource-use durations, the FIFO queue also gives starvation freedom for accepted requests, since later requests cannot overtake them.
Mutual exclusion Created 2026-10-14 Updated 2026-10-25
Mutual exclusion allows at most one participating software thread at a time to execute a protected critical section. A mutex is an object used to enforce that rule; the critical section is the region of the program that needs the rule. Several different critical sections can use the same mutex to protect the same shared data. The benefit is reasoning about a complete update without another cooperating software thread observing or changing its intermediate state.[ref]
For a small lost update, shared Assume sequential consistency: each step is indivisible, each software thread keeps the displayed order, and a read sees the latest preceding write to
x initially equals . Each of two software threads, T1 and T2, uses its own local r and performs these three steps:r = read(x)
r = r + 1
write(x, r)x. In the thread interleaving T1 read, T2 read, T1 add, T2 add, T1 write, T2 write, both local values become and both writes store . Final instead of : a lost update despite two correctly executed local additions. Separate indivisible reads and writes are insufficient; the complete read, modify and write must be protected.The binomial coefficient counts the thread interleavings preserving the two three-step orders: choose T1's three positions, with the remaining positions belonging to T2. Exhaustive enumeration gives final in 18 orders and in the two serial orders. These counts are not probabilities: no random scheduler has been specified. With the same mutex acquired before reading and released after writing, only the two complete increment orders remain, and both give . Alternatively, an atomic read-modify-write increment updates
x in one indivisible step. Protecting only the write still allows both software threads to read beforehand.Mutual exclusion is a safety property: two participants must never be inside the protected critical section together. Eventual entry for every persistent requester is a liveness property, expressed here as starvation freedom. A protocol that never admits anyone satisfies the first requirement while failing the second. Nor does a mutex alone promise which waiting software thread enters next, or that a producer runs before a consumer. Such application ordering needs an additional synchronization protocol.[ref]
Defining Liveness by Bowen Alpern and others. pp. 181–182: mutual exclusion, finite witnesses to safety violations, and eventual service
The sequential consistency assumptions delimit this calculation. In C++, unsynchronized conflicting accesses to an ordinary shared object can be a data race, which makes behavior undefined; the 20 schedules are not a prediction for that program. An atomic operation with relaxed ordering also supplies no acquire-release synchronization for other data. A real mutex must supply both exclusive entry and the required happens-before ordering between its users.[ref]
Nonpreemptive strict-priority arbitration 2026-10-24
At each service decision, choose the highest-priority pending request, preserving FIFO queue order within a priority class. A running owner retains the resource until it releases it; a higher-priority arrival changes the next choice rather than interrupting current work. Two priority classes can be represented by two FIFO queues, consulting the urgent one first.
This policy preserves the ownership safety argument of a message-passing mutual exclusion server. It does not by itself give starvation freedom to lower-priority requests when higher-priority traffic can continue indefinitely. Priority is evaluated on requests known to the arbiter at the decision point; a message not yet received cannot influence that decision.
Safety: only the driver accesses the sensor, and
active identifies at most one conversion. Accepted requests are serialized by the FIFO queue. The reply destination and token identify the owner of the resulting sample; no caller can clear another conversion's ready flag or consume another result. Receiving new requests while busy only changes the queue, not the active measurement. These are mutual exclusion and request/result association properties, not timing guesses.Progress: assume each started conversion completes in finite time, the corresponding notification is eventually delivered, the driver and compliant clients are eventually scheduled, and pending message acceptance is fair. A caller remains ready to receive its reply. Every accepted request has finitely many earlier requests in the queue, and later arrivals cannot overtake it. Each earlier request is completed and removed in finite time, so the caller eventually becomes active and receives its own reading. Fair acceptance extends this argument from accepted requests to callers waiting to submit one.
These assumptions are necessary for starvation freedom. A failed sensor, a client that disappears before accepting a synchronous reply, or an unfair scheduler can prevent progress; serialization alone cannot prove otherwise. Under the stated operating model, simultaneous calls are safe and every call completes. A single shared “latest temperature” variable would not establish either a fresh conversion per call or correct reply ownership.
Use two FIFO queues, one for each priority class, and perform nonpreemptive strict-priority arbitration whenever the display becomes free:The same ownership invariant proves mutual exclusion. Among requests already accepted by the server, every pending urgent request takes precedence over every ordinary one. Each class retains its own arrival order. A newly received urgent request goes ahead of waiting ordinary requests but waits for the current animation's
owner = NONE
ordinary = empty FIFO queue
urgent = empty FIFO queue
forever:
message = receive_from_any_client()
if message.kind == REQUEST:
assert message.priority in {0, 1}
if message.priority == 1:
urgent.push_back(message.client)
else:
ordinary.push_back(message.client)
else if message.kind == RELEASE:
assert message.client == owner
owner = NONE
if owner == NONE:
if not urgent.empty():
owner = urgent.pop_front()
else if not ordinary.empty():
owner = ordinary.pop_front()
if owner != NONE:
send(owner, GRANT)RELEASE; the given protocol has no interruption or revocation operation.This is strict priority at dispatch, based on requests the server has received. Requests still in transit cannot influence a decision. If the transport provides a mailbox-draining operation, the server may also collect all currently delivered requests before dispatching; the two-FIFO queue selection rule remains the same.
Strict priority does not guarantee starvation freedom for ordinary clients under an endless supply of urgent work. If urgent traffic eventually stops, accepted requests have only finitely many earlier requests, and all service times are finite, every pending ordinary request is eventually granted. Guaranteeing ordinary progress under unlimited urgent traffic would require a different fairness policy, such as limiting consecutive urgent grants; that would relax strict priority.
A LIFO stack can make waiting clients starve. Suppose client waits at the bottom of the stack. Before each current owner releases, a fresh client submits a request. That newest request is pushed above and is selected next. Every animation can finish promptly while waits forever.
This is LIFO starvation: service completion alone does not ensure starvation freedom. A FIFO queue prevents newer same-priority requests from passing , whereas replacing either priority-class FIFO queue by a LIFO stack adds this problem even within one priority class. Strict priority can already starve ordinary work, as in (b); the LIFO stack introduces a further unfairness that can also affect urgent work.
Request-reply sensor conversion 2026-10-24
A device driver protocol giving each accepted client request its own fresh hardware conversion. A single driver owns the device registers, queues requests, starts one conversion, waits for its completion, reads the result and replies to the identified requester before starting the next conversion. Sender identity and a per-call token prevent reply confusion. A FIFO queue prevents later accepted requests from overtaking earlier ones.
Safety follows from at most one active conversion and exclusive register ownership. Starvation freedom additionally needs finite conversion time, eventual interrupt delivery, fair request acceptance and scheduling, and clients ready to receive their replies. These are progress assumptions, not consequences of mutual exclusion alone.
Spinlock 2026-10-14
A mechanism that waits for ownership by repeatedly trying while consuming CPU execution time. A spinlock built from test-and-set can enforce mutual exclusion without guaranteeing starvation freedom. Progress also requires the owner to run and release: if a waiting software thread monopolizes the only CPU while the owner is suspended, exclusive entry alone cannot help.[ref]
Starvation freedom 2026-10-14
For acquisition of a mutex, the guarantee that every persistent requester eventually succeeds, under specified scheduling assumptions and with owners eventually releasing. Some software threads repeatedly succeeding while another waits forever violates starvation freedom without violating mutual exclusion. A finite bound on the wait, and service in arrival order, are additional requirements.
