Synchronization Issues
2026-11-03
We have
So expect us to end around 4
This module: Concurrent programming with threads
Desiderata:
For shared memory (vs message-passing style):
Arc, Mutex, RwLock, and CondvarBasis for higher-level abstractions (work queues, parallel iteration, etc).
Which of these is statements about atomics is false?
SeqCst order, ops act as if interleaved across threads.Relaxed order, the only inter-thread happens-before relations are matched loads and stores.Respond at: https://PollEv.com/davidbindel252 or send davidbindel252 to 22333
Most synchronization errors are not deadlock!
“Serializability among multiple memory accesses is violated (i.e. a code region is intended to be atomic, but the atomicity is not enforced during execution).”
NB: Harder to get this with actor model.
Many issues ruled out in safe Rust!
“Desired order between two (groups of) memory accesses is flipped”
Relaxed)Rust doesn’t really help you with this.
What if the philosophers have enough utensils?
What if they put back a chopstick if they can’t get both?
(Can implement with try_lock on Mutex)
What if they can steal chopsticks?
What if they acquire chopsticks via a global order?
Bipartite graph with:
Cycles mean trouble!
(Coffmann, 1971)
Four necessary and sufficient conditions:
Prevention: Make one of the four conditions impossible!
RwLock vs Mutextry_lock for nonblocking attempt to lockOptimistic concurrency doesn’t deadlock:
Removes hold-and-wait.
Maybe more efficient than timeout?
Check for safety involves simulating future:
If loop completes, state is safe
Fundamentally, need to break ties!
Which is true?
Respond at: https://PollEv.com/davidbindel252 or send davidbindel252 to 22333
Various types of synchronization issues: