Level 2 of 12 · about 2 weeks
Threads
What a thread is, how to write safe threaded C with POSIX threads, and what several processors can and cannot give.
Modules
Core: everyone needs it. Common: most jobs use it. Specialist: optional depth, safe to skip on a first read.
1
Why threads exist
Several lines of execution inside one process, and what they share
Core 6 parts · about 3 hours
2
POSIX threads
Creating, joining and ending threads with pthread_create and pthread_join
Core 6 parts · about 4 hours
3
User threads and kernel threads
Who knows about a thread: the library or the kernel
Core 7 parts · about 3 hours
4
Thread-safe code and thread-local data
Why shared data goes wrong, which library functions are safe, and how to give each thread its own copy
Core 7 parts · about 4 hours
5
Thread pools and event loops
Two ways to serve many tasks without a thread for each one
Core 7 parts · about 4 hours
6
Multicore basics
What several processors give a threaded program, and what limits the gain
Core 7 parts · about 4 hours
7
Case study, a threaded server
One small network service built three ways, tested and compared
Core 7 parts · about 5 hours