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/kdata.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/kdata.asm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/kdata.asm b/src/kdata.asm index ba395f1..5b91030 100644 --- a/src/kdata.asm +++ b/src/kdata.asm @@ -21,8 +21,8 @@ wTmpSlot:: DS 1 wTmpPid:: DS 1 wTmpSP:: DS 2 -; cart-RAM bank allocator (bump; bank 0 taken by the init task) -wNextRamBank:: DS 1 +; cart-RAM bank allocator: 0 = free, 1 = in use. bank 0 is the init task's. +wBankUsed:: DS NUM_RAM_BANKS ; scratch used by sys_fork wForkUserSP:: DS 2 ; parent user SP at fork entry (= Uafter) @@ -31,3 +31,10 @@ wForkChildPid:: DS 1 wForkParentBank::DS 1 wForkChildBank:: DS 1 wCopyBuf:: DS 256 ; bank-copy bounce buffer (WRAM0, always mapped) + +; scratch used by sys_exit / sys_wait +wExitMyPid:: DS 1 +wExitParentPid:: DS 1 +wWaitMyPid:: DS 1 +wWaitRetPid:: DS 1 +wWaitRetCode:: DS 1 |
