aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-16 11:15:12 +0200
committeruser <user@clank>2026-07-16 11:15:12 +0200
commitbb4f468b73c8a888bec1e5b2ba7f1575ab7f8456 (patch)
tree24e681e7ca242f3041f6a3effa197445ada451fb /README.md
parentkill + ps: implement SYS_KILL (pid 1 immortal) and a ps tool (diff)
downloadgbos-bb4f468b73c8a888bec1e5b2ba7f1575ab7f8456.tar.gz
gbos-bb4f468b73c8a888bec1e5b2ba7f1575ab7f8456.tar.xz
gbos-bb4f468b73c8a888bec1e5b2ba7f1575ab7f8456.zip
jobs: background execution (&), non-blocking reap, spin demo
- sys_reap: nohang reap of a finished zombie child (-> pid or 0). - shell: 'cmd &' launches in the background (prints [pid], no wait); reaps finished jobs at the prompt ([pid done]). Foreground now waits for its own child specifically (loops wait(), reporting bg completions meanwhile) so kill reports the right pid. - spin: a process that yields forever - a target for ps/kill. - verified: spin &; ps shows it; kill <pid> removes just that one; immortal init; self-finishing bg worker reaped with [pid done].
Diffstat (limited to 'README.md')
-rw-r--r--README.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/README.md b/README.md
index b0a2edf..fe8a930 100644
--- a/README.md
+++ b/README.md
@@ -263,6 +263,35 @@ so we use SDCC's native asxxxx path and INCBIN the blob instead. String literals
with embedded control chars are also mangled in rgbds mode; C programs pass
explicit lengths and emit newlines via `nl()`.
+## Processes & jobs
+
+Every process has a **pid** (1–255, monotonic) and a parent. `getpid`, `wait`,
+and a full lifecycle (`fork`/`exec`/`exit`/reaping) already existed; on top of
+that:
+
+- **`ps`** lists live processes (`pid state command`); state is `R`eady,
+ `B`locked (in `wait`), or `Z`ombie. The PCB records the running program id
+ (`PROC_PROG`) so `ps` can show names.
+- **`kill <pid>`** terminates a process (`sys_kill`): marks it a zombie,
+ reparents its children to init, wakes a `wait`-blocked parent. **pid 1
+ (init/the shell) is immortal** — `kill 1` is refused.
+- **Background jobs:** `cmd &` runs without waiting; the shell prints `[pid]`
+ and reaps finished jobs (non-blocking `reap`), printing `[pid done]`.
+
+```
+$ spin & # a process that just yields forever
+[2]
+$ ps
+1 B sh
+2 R spin
+3 R ps
+$ kill 2
+[2 done]
+$ ps
+1 B sh
+5 R ps
+```
+
## Filesystem
A tiny **RAM filesystem** lives in **WRAMX (`$D000-$DFFF`, 4 KiB)** — always