Concurrency in Computer Systems
Problem Explain concurrency in computer systems.
Be ready to discuss
- The definition: a system making progress on multiple tasks over overlapping time periods, whether by true parallel execution on multiple cores or interleaved execution on one core via context switching.
- Concurrency vs parallelism: dealing with many things at once (a structuring concern) vs doing many things at once (an execution concern) - concurrency enables parallelism but does not require it.
- Processes vs threads: separate address spaces and isolation vs shared memory and cheap context switches; where green threads/coroutines fit.
- Race conditions and critical sections: what goes wrong when shared mutable state is touched without synchronisation, and why the bugs are non-deterministic.
- Synchronisation primitives: mutexes, semaphores, condition variables, monitors, read-write locks, and atomics/CAS for lock-free work.
- The costs synchronisation introduces: contention, convoying, priority inversion, and the failure modes of deadlock, livelock, and starvation.
- Memory models and visibility: why reordering and caching mean a write in one thread isn't automatically visible in another, and what
volatile/memory barriers buy you. - Language-level models worth contrasting: Go's goroutines and channels (CSP), Java's ExecutorService and thread pools, async/await event loops, and the actor model.
asked …