SchOS/include
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz a5ff83de46 proc: real CPU time, a tty number, and an exe that is a symlink
Four Gate 0 rows, and a fifth found while checking one of them.

**getrusage() did not distinguish RUSAGE_CHILDREN from RUSAGE_SELF**, which
undersells it: it ignored `who` entirely and reported the machine's *uptime*
as the caller's user time. Every process of every age answered with the same
number. Per-process CPU time is sampled at the timer tick now and split on the
interrupted privilege level; children's time is rolled up in wait() rather than
exit(), because RUSAGE_CHILDREN means *reaped* children and a running one has
not contributed yet.

**And wait4()'s fourth argument is a `struct rusage *` that was read off the
stack and thrown away.** That is the one shells actually use -- wait3() is the
same syscall with pid -1 -- so zsh's `time` reported

    16777216.01s user 1073.78s system 927983249% cpu

for every command. 2^24 seconds is uninitialised memory, and it did not vary
with the workload because it was never written. Now:

    busy loop   2.66s user  97% cpu   2.720 total
    sleep 2     0.02s user   0% cpu   2.248 total
    ls -lR /    0.70s user  65% cpu   1.070 total

**ru_stime is a structural zero and says so.** MSR_SFMASK includes FL_IF, so
SYSCALL clears interrupts and no tick can land while a process is inside a
syscall. Tick sampling cannot see kernel time at all here. Charging it needs
TSC deltas closed and reopened around every sched(), which is scheduler
accounting rather than sampling; the limitation is written down in
docs/architecture/kernel.md rather than papered over.

**/proc/<pid>/exe is a symlink.** It also needed a real st_size, and every
other procfs file deliberately reports zero -- readlink(2) bounds its copy by
it, so a symlink of size 0 resolves to the empty string, which looks like it
worked and is worse than the regular file was. Generating that one path in
ilock() costs one small render per stat() of one file.

**OVMF memory reporting is closed**: 1 GB reports 1017 MB usable, 2 GB reports
2041 MB. The firmware keeps about 7 MB either way, which is the right shape.

**And `ps` printed a header and nothing else**, which is not in any list
because nobody had run it. `ps` with no arguments shows only processes on
*this* terminal; /proc/<pid>/stat hardcoded tty_nr to 0, so nothing could ever
match. `ps -e` always worked, which is exactly what hid it. p->ctty was already
tracked -- procfs simply was not asked. Fields 14..17 were hardcoded zero too,
so TIME read 00:00:00 however long a process had run; they carry the new
counters now, and a shell that has burned 653 ticks reports 00:00:06.

Verified: utime climbs 18 -> 653 across a loop in the shell itself, `ps` lists
its own terminal, `ps -e` still lists everything, `readlink /proc/1/exe` gives
/bin/schinit, and sigtest/$()/rename/dmesg are all still green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 02:45:00 +02:00
..
asm.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
buf.h Raise the disk ceiling: 64-bit blocks, no FSSIZE panic, LBA48 2026-08-10 18:50:31 +02:00
config_sinit.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
date.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
dbg.h debugger: D5, the network transport -- and the plan closes 2026-09-14 15:33:53 +02:00
defs.h proc: real CPU time, a tty number, and an exe that is a symlink 2026-09-22 02:45:00 +02:00
device.h docs: four directories, and a rule for when a thing leaves the roadmap 2026-09-12 17:13:35 +02:00
display.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
dma.h dma: the 4 MB cap was the refusal, not the arena 2026-09-14 22:52:20 +02:00
elf.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
errno.h schfs: a format version policy, and refusing is not falling back 2026-09-12 17:13:59 +02:00
fb.h Rename Schunix to SchOS; the kernel becomes SchIFT 2026-08-09 14:09:59 +02:00
fcntl.h Rename Schunix to SchOS; the kernel becomes SchIFT 2026-08-09 14:09:59 +02:00
file.h fs: devtmpfs, so /dev is generated rather than written to a disk 2026-09-12 20:18:30 +02:00
font.h Rename Schunix to SchOS; the kernel becomes SchIFT 2026-08-09 14:09:59 +02:00
fs.h init survives stray signals; commands are 4-34x faster 2026-08-09 15:54:05 +02:00
fsstat.h fs: timestamps come from the clock, and /proc/fsstat says how full the tables are 2026-09-12 17:14:14 +02:00
gfx.h font: the console draws outlines now, and a byte could not have held Ą 2026-09-20 00:35:34 +02:00
input.h usb-hid: bind an absolute pointer, and plumb EV_ABS through 2026-08-10 18:27:01 +02:00
ioperm.h ldls: a second driver, and everything it found 2026-09-14 15:20:07 +02:00
irq.h hybrid: interrupts to userspace, and a crashed driver that stays crashed 2026-09-13 18:11:00 +02:00
kbd.h kbd: three layouts, and the arrow keys were sitting on top of UTF-8 2026-09-20 01:09:32 +02:00
keymap.h kbd: three layouts, and the arrow keys were sitting on top of UTF-8 2026-09-20 01:09:32 +02:00
klog.h debugger: D5, the network transport -- and the plan closes 2026-09-14 15:33:53 +02:00
logo.h docs: a branding folder, and the three marks are not interchangeable 2026-09-12 18:19:09 +02:00
memlayout.h Free every usable memory region, not one contiguous run 2026-08-09 20:03:51 +02:00
mmu.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
mp.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
netdev.h net: a frame wakes the stack, instead of waiting for the clock 2026-09-12 17:23:46 +02:00
netuser.h ldls: L4 was free after all, and the plan closes 2026-09-14 13:37:04 +02:00
param.h kstack: 3736 of 4096 bytes, measured, and the AP got a page it did not own 2026-09-21 21:05:15 +02:00
pci.h hybrid: the GPU driver now runs in userspace 2026-09-13 18:27:41 +02:00
pciuser.h hybrid: the GPU driver now runs in userspace 2026-09-13 18:27:41 +02:00
posix.h signal: the return trampoline was Linux-only, and a test that proves the rest 2026-09-21 23:56:34 +02:00
proc.h proc: real CPU time, a tty number, and an exe that is a symlink 2026-09-22 02:45:00 +02:00
qr.h docs: four directories, and a rule for when a thing leaves the roadmap 2026-09-12 17:13:35 +02:00
sbuf.h debugger: D5, the network transport -- and the plan closes 2026-09-14 15:33:53 +02:00
schboot.h boot/uefi: the memory map the kernel gets is the one the firmware agreed to 2026-08-11 11:42:22 +02:00
schfs.h schfs: records at arbitrary offsets are packed, and the compiler is told 2026-09-12 17:56:36 +02:00
schinit.h hybrid: the driver is killed, and the driver comes back 2026-09-14 00:05:43 +02:00
sleeplock.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
socket.h debugger: D5, the network transport -- and the plan closes 2026-09-14 15:33:53 +02:00
spinlock.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
stat.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
syscall.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
text.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
theme.h gfx: the console and the crash screen stop drawing on a driver by name 2026-08-15 17:04:10 +02:00
traps.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
ttf.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
types.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
uaccess.h Rename Schunix to SchOS; the kernel becomes SchIFT 2026-08-09 14:09:59 +02:00
usb.h usb-hid: bind an absolute pointer, and plumb EV_ABS through 2026-08-10 18:27:01 +02:00
user.h signal: the return trampoline was Linux-only, and a test that proves the rest 2026-09-21 23:56:34 +02:00
virtio.h hybrid: a modeset, from a process 2026-09-14 01:36:05 +02:00
vt.h font: the console draws outlines now, and a byte could not have held Ą 2026-09-20 00:35:34 +02:00
x86.h schfs: the commit barrier, reflink, and attributes with an index over them 2026-08-15 16:02:02 +02:00