git.cappig.dev / apheleiaOS.git master

9ca6f71ecc24bdda5932d4b126e0fd889b1f34ef master
cappig <[email protected]> ยท 4 months ago
Add procfs, replace process syscalls with /proc interface

* Add procfs subsystem (procfs.c/h): create /proc/<pid>/{stat,pid,
  ppid,uid,gid,pgid,sid} and /proc/self; register/unregister entries
  on thread create and destroy
* Replace sched_list_procs() with sched_proc_snapshot(pid, snapshot);
  move get/set uid, gid, pgid, setsid logic into scheduler; add
  cpu_time_ticks field and accumulate in sched_tick
* Remove SYS_GETPID, SYS_GETPPID, SYS_GETUID/GID, SYS_SETUID/GID,
  SYS_SETPGID/GETPGID, SYS_SETSID, SYS_GETPROCS from the syscall
  table and renumber the remaining entries
* Re-implement getpid, getppid, getuid, getgid, setuid, setgid,
  getpgid, setpgid, setsid in libc_usr via /proc reads and writes;
  add proc_stat_parse() and proc_stat_read() helpers in proc.c
* Rewrite ps and shell pgrp_state() to enumerate /proc via getdents
  and read per-process stat files instead of calling getprocs()
13 files changed, 1147 insertions, 280 deletions
kernel/main.c +5 -0
kernel/sched/scheduler.c +178 -40
kernel/sched/scheduler.h +24 -1
kernel/sys/procfs.c created
kernel/sys/procfs.h created
kernel/sys/syscall.c +0 -159
libs/libc/sys/proc.h +18 -14
libs/libc/unistd.h +10 -22
libs/libc_usr/proc.c created
libs/libc_usr/unistd.c +122 -13
libs/libc_usr/unistd.h +0 -1
user/ps/main.c +76 -17
user/sh/main.c +42 -13