CSE Roadmap

Core tier · about 5 hours · 8 parts

Part 1 of 8 · 1 min read

Why this page comes last in the level

In this module you will

  • Follow a routine for a hung program: observe, reproduce, take a thread dump, read the cycle, fix, verify.
  • Read a debugger listing of lock owners and turn it into a wait-for cycle.
  • Use ThreadSanitizer and Helgrind to find a lock-order mistake before it freezes anything.
  • Fix a deadlock by lock ordering and prove the fix with a stress run and a tool run.
  • Write a short report of the problem with its cause, fix and prevention.

Pages 1 to 6 gave the theory, the pictures, the cures and the cousins. This page uses them together on one program, in the order that an engineer would meet them. The program is the four-account transfer service that earlier pages used in pieces. Its first version has the mistake of page 1: it takes two locks in the order of the arguments. The sources are the earlier pages of this level, OSC chapter 8 and the manuals of gdb, ThreadSanitizer and Valgrind. All programs were compiled with gcc -g -O1 -pthread on a two-processor Linux 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.