Chapter 21 — Process Teardown and Address-Space Cleanup

Chapter 21 — Process Teardown and Address-Space Cleanup
This entry is part 20 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 20, we added the TOYEXE loader: But there is still a lifecycle problem. The process can exit, but we are not yet reclaiming everything it owns. Right now this leaks: This chapter closes that loop. After this chapter, the process lifecycle becomes: The milestone output will look like: 1. What this chapter adds

Chapter 23 — Building a Real User C Program and Embedding Its ELF

Chapter 23 — Building a Real User C Program and Embedding Its ELF
This entry is part 21 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 22, the kernel gained a first ELF32 loader. That was a big step, but our test ELF was still built by hand inside process.c: This chapter removes that artificial piece. We will add a tiny userland build pipeline: GNU objcopy is specifically designed to copy and transform object files between formats; we will

Chapter 24 — User argc / argv and a Real Initial Stack

Chapter 24 — User argc / argv and a Real Initial Stack
This entry is part 22 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 23, we crossed another major boundary: But the user program still started like this: That is not how we want user programs to look long-term. This chapter adds a real initial user stack with: Then crt0.S will pass those arguments to: This moves us closer to a normal process startup model. ELF process

Chapter 26 — Process Table, ps, runbg, and wait PID

Chapter 26 — Process Table, ps, runbg, and wait PID
This entry is part 23 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 25, the monitor gained an embedded program registry and a foreground run command: That gave us an exec-like path, but only in foreground mode: This chapter adds the next process-management layer: After this chapter, the monitor will support: The kernel still does not have job control, signals, or a filesystem, but it now

Chapter 27 — A Second User Program for Safe Background Execution

This entry is part 24 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 26, we added: That gave us a real background process path. But our only user program, demo, waits for terminal input: That makes it awkward for runbg, because a background process can compete with the monitor for keyboard input. This chapter adds a second embedded user program: counter does not read from stdin.

Chapter 28 — Pattern-Based User Program Build System

Chapter 28 — Pattern-Based User Program Build System
This entry is part 25 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 27, we added a second user program: That proved the program registry can handle more than one embedded ELF. But the Makefile now has duplicated build rules: That will not scale. This chapter cleans up the user-program build system so adding a new user program is mostly: and then adding: The build system

Chapter 29 — First Userland Runtime

Chapter 29 — First Userland Runtime
This entry is part 26 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 28, we cleaned up the user-program build system: now automatically builds: But our user programs still duplicate small helper functions: Both demo.c and counter.c contain nearly the same code. This chapter adds the first tiny Toyix userland support library: This is not a real libc yet, but it is the beginning of one.

Chapter 30 — First User-Mode Shell

Chapter 30 — First User-Mode Shell
This entry is part 27 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 29, we added the first shared userland runtime. This chapter extends that runtime with formatted output and shell-oriented helpers, then uses it to build the first real long-running user-mode program: This first shell will run entirely in ring 3. It will read lines from stdin, parse commands, and execute a few built-in commands.

Chapter 31 — SYS_EXEC, SYS_WAITPID, and Shell-Launched Programs

Chapter 31 — SYS_EXEC, SYS_WAITPID, and Shell-Launched Programs
This entry is part 28 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 30, Toyix gained its first user-mode shell: But the shell could not launch programs yet. The kernel monitor could run programs: but the user shell could not. This chapter adds the first user-facing process-control syscalls: At first, SYS_EXEC still launches programs from the embedded program registry. We are not loading from a filesystem

Chapter 32 — Process Ownership, Waiting, and Job State

Chapter 32 — Process Ownership, Waiting, and Job State
This entry is part 29 of 30 in the series Writing A Linux Style Operating System From Scratch

In Chapter 32, the user shell gained: That let a user process launch another user process: The flow worked: But the process model was too loose. Any process could wait for any PID. This chapter tightens that up. We will add: After this chapter, a child process belongs to the process that launched it: Then: