aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-16 00:12:43 +0200
committeruser <user@clank>2026-07-16 00:12:43 +0200
commit19a2b63bab71b796ee456b3ae8bec1a2ab297158 (patch)
tree49b1effd335d47e859002903caea337fea27e1b9 /include
parentkernel: implement exec() (diff)
downloadgbos-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 'include')
-rw-r--r--include/gbos.inc4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/gbos.inc b/include/gbos.inc
index e15f7cb..7919bd6 100644
--- a/include/gbos.inc
+++ b/include/gbos.inc
@@ -48,6 +48,7 @@ DEF KSTACK_TOP EQU $D000 ; kernel stack top (grows down into WRAM0)
DEF MAX_PROCS EQU 8
DEF NUM_RAM_BANKS EQU 4 ; MBC5 cart RAM banks available (-r 3 = 32 KiB)
DEF KSTACK_TOP2 EQU $D000 ; kernel stack top reused for syscalls (fork)
+DEF INIT_PID EQU 1 ; pid of the init task (orphan reaper)
; process states
DEF PS_FREE EQU 0
@@ -88,7 +89,6 @@ DEF SYS_MAX EQU 12
; -----------------------------------------------------------------------------
; Program table indices (see programs.asm). exec() takes one of these in B.
; -----------------------------------------------------------------------------
-DEF PROG_PING EQU 0
-DEF PROG_PONG EQU 1
+DEF PROG_WORKER EQU 0
ENDC