Part 1 of 7 · 1 min read
Why this page comes sixth
In this module you will
- Read the number of processors, cores and caches of a Linux machine.
- Compute speed-up and efficiency from timings.
- Use Amdahl's law to predict the best speed-up of a program with a serial part.
- Explain false sharing and show it with a program.
- Pin a program to chosen processors.
Page 3 showed that kernel threads can run at the same moment on different processors. This page asks the next question: how much faster does a program get, and what stops it from getting faster still? The answers explain why adding threads often brings less than expected, and why some programs get slower. The main sources are "Operating System Concepts" (OSC), chapter 4, "Operating Systems: Three Easy Pieces" (OSTEP), chapters 10 and 28, and "Modern Operating Systems" (MOS), chapter 8. All programs were compiled with gcc -Wall -Wextra -pthread and run on a machine with two processors, so the measured speed-ups cannot go above 2 and the larger numbers in the tables are computed, and marked as such.
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.