From 2d3597c3a02f821bb364b8ecc23fc5949fca738d Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Jul 2026 11:10:45 +0200 Subject: kill + ps: implement SYS_KILL (pid 1 immortal) and a ps tool - PCB gains PROC_PROG (running program id), set by exec, inherited on fork. - sys_kill(pid): reject pid 1 (immortal) and unknown/dead pids; mark the target zombie, reparent its children to init, wake its parent if blocked in wait; schedule away if a process kills itself. Reuses FindPcbByPid/ReparentToInit. - sys_ps(slot,buf)->{pid,state,prog}; sys_progname(id) via NameTable reverse lookup. NameTable gains sh/ps/kill. - libc: kill/psget/progname; tools ps (pid state cmd) and kill . - verified: ps lists sh(B)+ps(R); kill 1 refused; kill 42 fails. --- c/libc.s | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'c/libc.s') diff --git a/c/libc.s b/c/libc.s index 857a16d..bcc8199 100644 --- a/c/libc.s +++ b/c/libc.s @@ -167,3 +167,23 @@ _lookup: ld c, #19 ; SYS_LOOKUP rst #0x30 ret + + .globl _kill, _psget, _progname + ;; unsigned char kill(unsigned char pid /*A*/) -> A (0 ok, $FF fail) +_kill: + ld b, a + ld c, #9 ; SYS_KILL + rst #0x30 + ret + ;; unsigned char psget(unsigned char slot /*A*/, unsigned char *buf /*DE*/) -> A +_psget: + ld b, a + ld c, #20 ; SYS_PS + rst #0x30 + ret + ;; void progname(unsigned char id /*A*/, char *buf /*DE*/) +_progname: + ld b, a + ld c, #21 ; SYS_PROGNAME + rst #0x30 + ret -- cgit v1.3.1-sl0p