Part 1 of 7 · 1 min read
Why this page comes last in the level
In this module you will
- Write a small TCP server that serves many clients with threads.
- Build it two ways, one thread per connection and a fixed pool, and test both.
- Predict the finishing time of a pool server from its size and the number of clients.
- Name the limits that decide how many threads a server can use.
- Choose a design for a given workload and explain the trade-off.
Pages 1 to 6 built the parts: threads, the POSIX calls, the kernel's role, safe shared data, pools and event loops, and the limits of multicore hardware. This page puts them in one program that real services resemble. It also prepares Level 3, where the question changes from "how many threads" to "which thread runs next". The sources are "Operating Systems: Three Easy Pieces" (OSTEP), chapter 27, "Operating System Concepts" (OSC), chapter 4, and "The Linux Programming Interface" (TLPI), chapters 56 to 61. All programs were compiled with gcc -Wall -Wextra -pthread -O2 on the two-processor test machine.
About this example About this example
Real: The C programs, commands and outputs on this page were compiled with gcc -Wall -Wextra -pthread and run on a Linux test machine (2 processors, kernel 6.18, glibc 2.39).
Scripted: The worked traces use small numbers chosen so they can be followed by hand.
Not real: The page simplifies real systems. Actual kernels add more cases, limits and tuning than a short page can show.