fork and exec are two halves of one pattern: fork cheaply duplicates the process, exec throws the duplicate away and loads a new program. This diagram shows the fork side first — task_struct cloned, page tables copied with every page marked copy-on-write so the first write in either process faults a private copy — then the exec side: old mappings torn down, the ELF loader mapping segments, and the entry point running main. The ordering matters because the design is why fork is fast: no memory is actually copied, only permission bits flipped. The done state: a new program runs in a fresh address space, and the two processes diverge from the moment the child writes its first byte.
Fork and Exec Flow
fork then exec: task_struct copy, copy-on-write page tables, ELF loading, and the handoff to main.
The Runtime Theory Team06 stages
trace / request.md
readyThe syscall handler begins duplicating the calling process: the task_struct is cloned, and the child gets its own PID — and its own return value from fork.