SchOS/kernel/fs
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz f4d7f9100d Threads
A thread is a struct proc that shares three counted objects with others of
its group: the address space (struct mm: page tables, heap top, VMAs and a
lock for changing them), the descriptor table, and the signal dispositions.
clone() shares what its flags say and fork() copies.

- clone(): pthread_create's shape (VM, FILES, SIGHAND, THREAD, SETTLS,
  PARENT_SETTID, CHILD_CLEARTID) and posix_spawn's (VM, VFORK, a stack).
- futex: WAIT, WAIT_BITSET with timeouts, WAKE, REQUEUE, CMP_REQUEUE, keyed
  by the word's kernel address so shared pages meet. set_tid_address keeps
  the word that exit zeroes and wakes, for pthread_join.
- exit ends a thread; exit_group, a fatal signal, or the leader exiting ends
  them all. reapd frees exited threads; the leader is reaped by its parent
  once the rest are gone. getpid is the group, gettid the thread.
- Stops and resumes reach every thread; other process signals the leader.
- exec kills the other threads and unshares the dispositions.
- No TLB shootdown, so pages unmapped from a shared address space are freed
  only once every CPU has reloaded CR3 or is idle.
- procfs: /proc lists processes, task/ lists threads, comm, Threads:, Tgid.
- The console honours VMIN 0 / VTIME (btop's input drain hung on it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
2026-10-25 03:03:50 +01:00
..
fat include: one folder per subsystem, and includes that name it 2026-10-23 15:05:12 +02:00
schfs Pseudo-terminals, and what tmux and htop needed around them 2026-10-25 02:11:10 +01:00
devfs.c Pseudo-terminals, and what tmux and htop needed around them 2026-10-25 02:11:10 +01:00
exec.c Threads 2026-10-25 03:03:50 +01:00
file.c Pseudo-terminals, and what tmux and htop needed around them 2026-10-25 02:11:10 +01:00
fs.c Pseudo-terminals, and what tmux and htop needed around them 2026-10-25 02:11:10 +01:00
lock.c flock, fcntl record locks 2026-10-24 12:22:36 +02:00
log.c include: one folder per subsystem, and includes that name it 2026-10-23 15:05:12 +02:00
pipe.c Job control, function keys, and real sleeps 2026-10-25 02:37:45 +01:00
procfs.c Threads 2026-10-25 03:03:50 +01:00
sysfs.c input, fb, vt, sysfs: the kernel calls Xorg makes 2026-10-24 12:06:04 +02:00