One Fork, Two Paths¶
Exercise: 51k_fork_wait · Thu Dec 3 · Length: 6:36 · Reading: Week 15 · One call, two returns · Explainer: One Fork, Two Paths
A narrated walk through the explainer, for before Thursday's session (Dec 3),
to go with the Week 15 reading
fork, wait, and the User Shell:
fork makes a second process running the caller's
program from the same place, and a fork that makes no child answers the
caller alone. The video reads an example program that writes a line, calls
fork once and then branches, then steps through its fork on the reference
kernel, watching the CPU, two slots of the process table and each call's
answer as the processes resume. The skeleton follows, whose fork makes no
second process, with what the program prints; then the reference's whole run,
turn by turn. Then the skeleton and two other broken kernels, A and B, for
which the test prints the same first line, and kernel C, for which it prints
less. The video ends on what you write, the test's own programs, and how to
read a failure. It shows no solution code: only the process table's
slots, the registers and each call's answer at each step, with an example
program, or the test's own.
Download the video (MP4, 8 MB) · Captions (WebVTT) · All eleven Week 15 videos