Concurrency is a property of some computations, where multiple threads of control overlap. Different constructs enable concurrent programs to be implemented in different ways.
The example implementations described in these videos are available as concurrent.zip.
- A look at problems with a sequential server and listing the options that we’ll consider to make it handle multiple connections concurrently.
- Adjusting the echo server to use an independent child process for every connection.
- Running the echo server with concurrency via fork, and using a client program that makes multiple connections at once to stress-test the server.
- A brief look at why processes are inconvenient when connections need to cooperate, such as keeping a running total of message sizes.
- An introduction to threads.
- A small example program that creates a thread using pthread_create.
- Using pthread_join to wait for a thread to complete and to receive its result value.
- Unlike processes, threads are not arranged in a hierarchy. As a consequence, different threads created by the main thread can wait on each other.
- A brief explanation of pthread_detach.
- Using threads to implement concurrent handling of connections in the echo server.
- An alternative to concurrency via processes or threads is to explicitly cycle through connections and rely on select to report which connections are ready. Each “ready” reported by select is a kind of event to be handled, and then the server goes back to waiting with select.
- Making the echo server handle concurrent connections by using select to multiplex I/O.
- A summary of the three options that we tried for making the echo server concurrent and the trade-offs of each.