The example implementations described in these videos are available as concurrent.zip.
- Demonstration of how naive sharing of a counter fails in the echo server.
- One reason that naive sharing fails: the read–update–write sequence in machine code might not be a single instruction.
- Another reason that naive sharing fails is that multiprocessors create races even for single-instruction operations.
- Also, a compiler may treat code different as intended for naive sharing. Concurrent programs must use some explicit form of synchronization.
- Processors typically provide a compare-and-swap operation as a primitive building block for synchronization.
- A lock provides a compare-and-swap kind of atomicity for larger groups of instructions.
- Mutexes and semaphores are common lock abstractions.
- We’ll use a particular semaphore API, described in this video, for improving the echo server.
- Updating the echo server to use semaphores, both as a mutex to guard the counter variable and as a signaling mechanism when a thread has received its file descriptor.
- Demonstrating per-object locks with counter objects.
- Towards a thread-safe queue that can be used by an echo server to dispatch file descriptors to a fixed set of echo threads.
- Implementing a thread-safe queue and adapting the echo server to use it.
- A note on thread-safe functions and the C library.
- A note about the differences and relationship between concurrency and parallelism.