diff options
| author | user <user@clank> | 2026-07-16 00:12:43 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-07-16 00:12:43 +0200 |
| commit | 19a2b63bab71b796ee456b3ae8bec1a2ab297158 (patch) | |
| tree | 49b1effd335d47e859002903caea337fea27e1b9 /src/sched.asm | |
| parent | kernel: implement exec() (diff) | |
| download | gbos-19a2b63bab71b796ee456b3ae8bec1a2ab297158.tar.gz gbos-19a2b63bab71b796ee456b3ae8bec1a2ab297158.tar.xz gbos-19a2b63bab71b796ee456b3ae8bec1a2ab297158.zip | |
kernel: complete the process lifecycle (exit/wait/reap + bank free list)
- exit(): zombie + status, reparent orphans to init, wake blocked parent,
schedule away forever (resources reclaimed by the reaper)
- wait(): scan for a zombie child; reap (free cart-RAM bank + PCB slot) and
return pid/code; block PS_BLOCKED + yield if children still live; $FF if none
- cart-RAM banks are now a free list (wBankUsed bitmap): AllocRamBank/FreeRamBank
- scheduler: FindNextReady returns carry when nothing runnable; yield idles
instead of blindly picking slot 0
- helpers: FindPcbByPid, ReparentToInit
- demo: init forks 3 workers -> exec -> exit(pid) -> wait/reap => wwwR2R3R4!
verified bank recycling with 6 workers over 3 banks (w2w3w4w5w6w7)
- README: document the lifecycle + syscall status
Diffstat (limited to '')
| -rw-r--r-- | src/sched.asm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/sched.asm b/src/sched.asm index c871f7a..a540c49 100644 --- a/src/sched.asm +++ b/src/sched.asm @@ -31,13 +31,14 @@ SchedRunFirst:: ; caller when this task is eventually rescheduled. ; ----------------------------------------------------------------------------- SchedYield:: - call FindNextReady ; DE = &next PCB + call FindNextReady ; DE = &next PCB, CF if none runnable + ret c ; nobody else ready: keep running current call hSwitchTo ret ; ----------------------------------------------------------------------------- -; FindNextReady - round-robin from wSchedNext. out: DE = &PCB (updates cursor) -; Scaffold: assumes at least one PS_READY task exists. +; FindNextReady - round-robin from wSchedNext. +; out: DE = &PCB and CF clear on success; CF set if nothing is PS_READY. ; ----------------------------------------------------------------------------- FindNextReady:: ld a, [wSchedNext] @@ -56,14 +57,13 @@ FindNextReady:: pop af ; restore candidate slot dec b jr nz, .scan - ; nothing ready: fall back to slot 0 (idle behavior) - xor a - call PcbPtr + scf ; nothing runnable ret .found pop af ; A = chosen slot ld [wSchedNext], a call PcbPtr ; DE = &PCB + and a ; clear carry ret ; ----------------------------------------------------------------------------- |
