Viewing: POSIX_ROADMAP.md
πŸ“„ POSIX_ROADMAP.md (Read Only) β¬… To go back
# AdrOS POSIX Roadmap (Checklist)

This document tracks **what is already implemented** versus **what is missing** to reach a practical Unix-like system with full POSIX compatibility.

Notes:
- This is intentionally pragmatic: items are ordered to unlock userland capabilities quickly.
- Checkboxes reflect the current state of the `master` branch.

## Status Legend
- `[x]` implemented (works end-to-end, smoke-tested)
- `[~]` partial (exists but incomplete/limited)
- `[ ]` not implemented

---

## 1. Syscalls β€” File I/O

| Syscall | Status | Notes |
|---------|--------|-------|
| `open` | [x] | Supports `O_CREAT`, `O_TRUNC`, `O_APPEND`; works on diskfs, devfs, tmpfs, overlayfs |
| `openat` | [x] | `AT_FDCWD` supported; other dirfd values return `ENOSYS` |
| `read` | [x] | Files, pipes, TTY, PTY, sockets; `O_NONBLOCK` returns `EAGAIN` |
| `write` | [x] | Files, pipes, TTY, PTY, sockets; `O_NONBLOCK` returns `EAGAIN`; `O_APPEND` support |
| `close` | [x] | Refcounted file objects |
| `lseek` | [x] | `SEEK_SET`, `SEEK_CUR`, `SEEK_END` |
| `stat` | [x] | `struct stat` with mode/type/size/inode/uid/gid/nlink |
| `fstat` | [x] | |
| `fstatat` | [x] | `AT_FDCWD` supported |
| `dup` | [x] | |
| `dup2` | [x] | |
| `dup3` | [x] | Flags parameter |
| `pipe` | [x] | In-kernel ring buffer |
| `pipe2` | [x] | Supports `O_NONBLOCK` flag |
| `select` | [x] | Pipes, TTY, sockets |
| `poll` | [x] | Pipes, TTY, PTY, `/dev/null`, sockets |
| `ioctl` | [x] | `TCGETS`, `TCSETS`, `TIOCGPGRP`, `TIOCSPGRP`, `TIOCGWINSZ`, `TIOCSWINSZ` |
| `fcntl` | [x] | `F_GETFL`, `F_SETFL`, `F_GETFD`, `F_SETFD` |
| `getdents` | [x] | Generic across all VFS (diskfs, tmpfs, devfs, overlayfs, procfs) |
| `pread`/`pwrite` | [x] | Atomic read/write at offset without changing file position |
| `readv`/`writev` | [x] | Scatter/gather I/O via `struct iovec` |
| `truncate`/`ftruncate` | [x] | Truncate file to given length |
| `fsync`/`fdatasync` | [x] | No-op stubs (accepted β€” no write cache to flush) |

## 2. Syscalls β€” Directory & Path Operations

| Syscall | Status | Notes |
|---------|--------|-------|
| `mkdir` | [x] | diskfs |
| `rmdir` | [x] | diskfs; checks directory is empty (`ENOTEMPTY`) |
| `unlink` | [x] | diskfs; returns `EISDIR` for directories; respects hard link count |
| `unlinkat` | [x] | `AT_FDCWD` supported |
| `rename` | [x] | diskfs; handles same-type overwrite |
| `chdir` | [x] | Per-process `cwd` |
| `getcwd` | [x] | |
| `link` | [x] | Hard links in diskfs with `nlink` tracking and shared data blocks |
| `symlink` | [x] | Symbolic links in diskfs |
| `readlink` | [x] | |
| `chmod` | [x] | Set mode bits on VFS nodes |
| `chown` | [x] | Set uid/gid on VFS nodes |
| `access` | [x] | Permission checks (`R_OK`, `W_OK`, `X_OK`, `F_OK`) |
| `umask` | [x] | Per-process file creation mask |
| `realpath` | [x] | Userland ulibc implementation (resolves `.`, `..`, normalizes) |

## 3. Syscalls β€” Process Management

| Syscall | Status | Notes |
|---------|--------|-------|
| `fork` | [x] | Full COW implemented (`vmm_as_clone_user_cow` + `vmm_handle_cow_fault`) |
| `execve` | [x] | Loads ELF from VFS; argv/envp; `O_CLOEXEC` FDs closed; `PT_INTERP` support |
| `exit` / `_exit` | [x] | Closes FDs, marks zombie, notifies parent |
| `waitpid` | [x] | `-1` (any child), specific pid, `WNOHANG` |
| `getpid` | [x] | |
| `getppid` | [x] | |
| `gettid` | [x] | Returns per-thread ID |
| `setsid` | [x] | |
| `setpgid` | [x] | |
| `getpgrp` | [x] | |
| `getuid`/`getgid` | [x] | Per-process uid/gid |
| `geteuid`/`getegid` | [x] | Effective uid/gid |
| `setuid`/`setgid` | [x] | Set process uid/gid; permission checks (only root can set arbitrary) |
| `seteuid`/`setegid` | [x] | Set effective uid/gid; permission checks |
| `brk`/`sbrk` | [x] | `syscall_brk_impl()` β€” per-process heap break |
| `mmap`/`munmap` | [x] | Anonymous mappings, shared memory backing, and file-backed (fd) mappings |
| `clone` | [x] | Thread creation with `CLONE_VM`/`CLONE_FILES`/`CLONE_THREAD`/`CLONE_SETTLS` |
| `set_thread_area` | [x] | GDT-based TLS via GS segment (GDT entry 22, ring 3) |
| `nanosleep`/`sleep` | [x] | `syscall_nanosleep_impl()` with tick-based sleep |
| `clock_gettime` | [x] | `CLOCK_REALTIME` (RTC-backed) and `CLOCK_MONOTONIC` (TSC nanosecond precision) |
| `alarm` | [x] | Per-process alarm timer; delivers `SIGALRM` on expiry |
| `times` | [x] | Returns `struct tms` with per-process `utime`/`stime` accounting |
| `futex` | [x] | `FUTEX_WAIT`/`FUTEX_WAKE` with global waiter table |
| `waitid` | [x] | Extended wait with `P_PID`/`P_ALL`/`P_PGID` |
| `posix_spawn` | [x] | Efficient fork+exec in single syscall with file actions and attributes |
| `setitimer`/`getitimer` | [x] | `ITIMER_REAL`, `ITIMER_VIRTUAL`, `ITIMER_PROF` |
| `gettimeofday` | [x] | Returns wall-clock time (backed by RTC) |
| `mprotect` | [x] | Change memory protection flags on existing mappings |
| `getrlimit`/`setrlimit` | [x] | Get/set resource limits (`RLIMIT_NOFILE`, etc.) |
| `uname` | [x] | Returns system identification (sysname, nodename, release, version, machine) |
| `getrusage` | [x] | Returns resource usage statistics |
| `mount` | [x] | Runtime filesystem mounting (tmpfs, disk-based via `init_mount_fs`) |

## 4. Syscalls β€” Signals

| Syscall | Status | Notes |
|---------|--------|-------|
| `sigaction` | [x] | Installs handlers; `SA_SIGINFO` supported |
| `sigprocmask` | [x] | Block/unblock signals |
| `kill` | [x] | Send signal to process/group |
| `sigreturn` | [x] | Trampoline-based return from signal handlers |
| `raise` | [x] | ulibc implementation (`kill(getpid(), sig)`) |
| `sigpending` | [x] | Returns pending signal mask |
| `sigsuspend` | [x] | Atomically set signal mask and wait |
| `sigaltstack` | [x] | Alternate signal stack per-process (`ss_sp`/`ss_size`/`ss_flags`) |
| `sigqueue` | [x] | Queued real-time signals via `rt_sigqueueinfo` |
| Signal defaults | [x] | `SIGKILL`/`SIGSEGV`/`SIGUSR1`/`SIGINT`/`SIGTSTP`/`SIGTTOU`/`SIGTTIN`/`SIGQUIT`/`SIGALRM` handled |

## 4b. Syscalls β€” I/O Multiplexing (Advanced)

| Syscall | Status | Notes |
|---------|--------|-------|
| `epoll_create` | [x] | Creates epoll instance; returns fd |
| `epoll_ctl` | [x] | Add/modify/delete fd interest; `EPOLL_CTL_ADD`/`MOD`/`DEL` |
| `epoll_wait` | [x] | Wait for events on epoll fd; timeout support |
| `EPOLLET` (edge-triggered) | [x] | Edge-triggered epoll mode with level-to-edge semantics |
| `inotify_init` | [x] | Creates inotify instance; returns fd |
| `inotify_add_watch` | [x] | Add watch on path with event mask |
| `inotify_rm_watch` | [x] | Remove watch by descriptor |

## 5. File Descriptor Layer

| Feature | Status | Notes |
|---------|--------|-------|
| Per-process fd table | [x] | Up to `PROCESS_MAX_FILES` entries |
| Refcounted file objects | [x] | Shared across `dup`/`fork`/`clone` with atomic refcounts |
| File offset tracking | [x] | |
| `O_NONBLOCK` | [x] | Pipes, TTY, PTY, sockets via `fcntl` or `pipe2` |
| `O_CLOEXEC` | [x] | Close-on-exec via `pipe2`, `open` flags |
| `O_APPEND` | [x] | Append mode for `write()` β€” seeks to end before writing |
| `FD_CLOEXEC` via `fcntl` | [x] | `F_GETFD`/`F_SETFD` implemented; `execve` closes marked FDs |
| File locking (`flock`) | [x] | Advisory locking with per-inode lock table |

## 6. Filesystem / VFS

| Feature | Status | Notes |
|---------|--------|-------|
| VFS mount table | [x] | Up to 8 mounts |
| `vfs_lookup` path resolution | [x] | Absolute + relative (via `cwd`); follows symlinks |
| `fs_node_t` with `read`/`write`/`finddir`/`readdir` | [x] | |
| `struct vfs_dirent` (generic) | [x] | Unified format across all FS |
| **tmpfs** | [x] | In-memory; dirs + files; `readdir` |
| **overlayfs** | [x] | Copy-up; `readdir` delegates to upper/lower |
| **devfs** | [x] | `/dev/null`, `/dev/zero`, `/dev/random`, `/dev/urandom`, `/dev/console`, `/dev/tty`, `/dev/ptmx`, `/dev/pts/N`, `/dev/fb0`, `/dev/kbd` |
| **diskfs** (on-disk) | [x] | Hierarchical inodes; full POSIX ops; symlinks; hard links with `nlink` tracking |
| **persistfs** | [x] | Minimal persistence at `/persist` |
| **procfs** | [x] | `/proc/meminfo` + per-process `/proc/[pid]/status`, `/proc/[pid]/maps` |
| **FAT12/16/32** (full RW) | [x] | Unified FAT driver, auto-detection by cluster count (MS spec), 8.3 filenames, subdirs, cluster chain management, all VFS mutation ops (create/write/delete/mkdir/rmdir/rename/truncate) |
| **ext2** (full RW) | [x] | Superblock + block group descriptors, inode read/write, block/inode bitmaps, direct/indirect/doubly-indirect/triply-indirect block mapping, directory entry add/remove/split, hard links, symlinks (inline), create/write/delete/mkdir/rmdir/rename/truncate/link |
| Permissions (`uid`/`gid`/`euid`/`egid`/mode) | [x] | `chmod`, `chown` with permission checks; VFS `open()` enforces rwx bits vs process euid/egid and file uid/gid/mode |
| Hard links | [x] | `diskfs_link()` with shared data blocks and `nlink` tracking |
| Symbolic links | [x] | `symlink`, `readlink`; followed by VFS lookup | |

## 7. TTY / PTY

| Feature | Status | Notes |
|---------|--------|-------|
| Canonical input (line-buffered) | [x] | |
| Echo + backspace | [x] | |
| Blocking reads + wait queue | [x] | Generic `waitqueue_t` abstraction |
| `TCGETS`/`TCSETS` | [x] | Full termios with `c_cc[NCCS]` |
| `TIOCGPGRP`/`TIOCSPGRP` | [x] | |
| Job control (`SIGTTIN`/`SIGTTOU`) | [x] | Background pgrp enforcement |
| `isatty` (via `ioctl TCGETS`) | [x] | |
| PTY master/slave | [x] | `/dev/ptmx` + `/dev/pts/N` (dynamic, up to 8 pairs) |
| Non-blocking PTY I/O | [x] | |
| Raw mode (non-canonical) | [x] | Clear `ICANON` via `TCSETS` |
| VMIN/VTIME | [x] | Non-canonical timing with `c_cc[VMIN]`/`c_cc[VTIME]` |
| Signal characters (Ctrl+C → `SIGINT`, etc.) | [x] | Ctrl+C→SIGINT, Ctrl+Z→SIGTSTP, Ctrl+D→EOF, Ctrl+\\→SIGQUIT |
| Multiple PTY pairs | [x] | Up to `PTY_MAX_PAIRS=8`, dynamic `/dev/pts/N` |
| Window size (`TIOCGWINSZ`/`TIOCSWINSZ`) | [x] | Get/set `struct winsize` |

## 8. Memory Management

| Feature | Status | Notes |
|---------|--------|-------|
| PMM (bitmap allocator) | [x] | Spinlock-protected, frame refcounting |
| PMM contiguous block alloc | [x] | `pmm_alloc_blocks(count)` / `pmm_free_blocks()` for multi-page DMA |
| VMM (x86 PAE paging) | [x] | Higher-half kernel, recursive page directory, PAE mode |
| Per-process address spaces | [x] | PDPT + 4 PDs per process |
| Kernel heap (`kmalloc`/`kfree`) | [x] | 8MB Buddy Allocator (power-of-2 blocks 32B–8MB, circular free lists, buddy coalescing) |
| Slab allocator | [x] | `slab_cache_t` with free-list-in-place |
| W^X for user ELFs | [x] | Text segments read-only after load |
| SMEP | [x] | Enabled in CR4 if CPU supports |
| `brk`/`sbrk` | [x] | Per-process heap break |
| `mmap`/`munmap` | [x] | Anonymous mappings, shared memory backing, file-backed (fd) mappings |
| Shared memory (`shmget`/`shmat`/`shmdt`) | [x] | System V IPC style |
| Copy-on-write (COW) fork | [x] | PTE bit 9 as CoW marker + page fault handler |
| PAE + NX bit | [x] | PAE paging with NX (bit 63) on data segments |
| Guard pages | [x] | 32KB user stack with unmapped guard page below (triggers SIGSEGV on overflow); kernel stacks in guard-paged region at `0xC8000000` |
| ASLR | [x] | TSC-seeded xorshift32 PRNG; randomizes user stack base by up to 1MB per `execve` |
| vDSO shared page | [x] | Kernel-updated `tick_count` mapped read-only at `0x007FE000` in every user process |

## 9. Drivers & Hardware

| Feature | Status | Notes |
|---------|--------|-------|
| UART serial console | [x] | |
| VGA text console (x86) | [x] | |
| PS/2 keyboard | [x] | |
| PIT timer | [x] | |
| LAPIC timer | [x] | Calibrated, used when APIC available |
| ATA PIO (IDE) | [x] | Multi-drive support: 4 drives (hda/hdb/hdc/hdd) across 2 channels |
| ATA DMA (Bus Master IDE) | [x] | Bounce buffer + zero-copy direct DMA, PRDT, IRQ-coordinated |
| PCI enumeration | [x] | Full bus/slot/func scan with BAR + IRQ |
| ACPI (MADT parsing) | [x] | CPU topology + IOAPIC discovery |
| LAPIC + IOAPIC | [x] | Replaces legacy PIC; ISA edge-triggered + PCI level-triggered routing |
| SMP (multi-CPU boot) | [x] | 4 CPUs via INIT-SIPI-SIPI, per-CPU data via GS |
| CPUID feature detection | [x] | Leaf 0/1/7/extended; SMEP/SMAP detection |
| VBE framebuffer | [x] | Maps LFB, pixel drawing, font rendering; `/dev/fb0` device with `ioctl`/`mmap` |
| Raw keyboard (`/dev/kbd`) | [x] | PS/2 scancode ring buffer; non-blocking read for game input |
| SYSENTER fast syscall | [x] | MSR setup + handler |
| E1000 NIC (Intel 82540EM) | [x] | MMIO-based, IRQ-driven, lwIP integration |
| RTC (real-time clock) | [x] | CMOS RTC driver; provides wall-clock time for `CLOCK_REALTIME` |
| MTRR write-combining | [x] | `mtrr_init`/`mtrr_set_range` for variable-range MTRR programming |
| Kernel console (kconsole) | [x] | Interactive debug shell with readline, scrollback, command history |
| Virtio-blk | [x] | PCI legacy virtio-blk driver with virtqueue I/O |

## 10. Networking

| Feature | Status | Notes |
|---------|--------|-------|
| E1000 NIC driver | [x] | Intel 82540EM, MMIO, IRQ 11 via IOAPIC (level-triggered, active-low), interrupt-driven RX |
| lwIP TCP/IP stack | [x] | NO_SYS=0 threaded mode (kernel semaphores/mutexes/mailboxes), IPv4, static IP (10.0.2.15) |
| ICMP ping test | [x] | Kernel-level ping to QEMU gateway (10.0.2.2) during boot; verified via smoke test |
| `socket` | [x] | `AF_INET`, `SOCK_STREAM` (TCP), `SOCK_DGRAM` (UDP) |
| `bind`/`listen`/`accept` | [x] | TCP server support |
| `connect`/`send`/`recv` | [x] | TCP client support |
| `sendto`/`recvfrom` | [x] | UDP support |
| `sendmsg`/`recvmsg` | [x] | Scatter-gather I/O via `struct msghdr` + `struct iovec` |
| DNS resolver | [x] | lwIP DNS enabled; kernel `dns_resolve()` wrapper with async callback + timeout |
| `/etc/hosts` | [x] | Kernel-level hosts file parsing and lookup |
| `getaddrinfo` | [x] | Kernel-level hostname resolution with hosts file + DNS fallback |
| `setsockopt`/`getsockopt` | [x] | Set/get socket options |
| `shutdown` | [x] | Shutdown socket send/receive |
| `getpeername` | [x] | Get remote address of connected socket |
| `getsockname` | [x] | Get local address of socket |

## 11. Threads & Synchronization

| Feature | Status | Notes |
|---------|--------|-------|
| `clone` syscall | [x] | `CLONE_VM`, `CLONE_FILES`, `CLONE_THREAD`, `CLONE_SETTLS`, `CLONE_SIGHAND` |
| `gettid` syscall | [x] | Returns per-thread unique ID |
| `set_thread_area` | [x] | GDT entry 22, ring 3 data segment for user TLS via GS |
| Thread-group ID (tgid) | [x] | `getpid()` returns tgid for POSIX compliance |
| Shared address space | [x] | Threads share addr_space; thread reap doesn't destroy it |
| `CLONE_PARENT_SETTID` | [x] | Writes child tid to parent address |
| `CLONE_CHILD_CLEARTID` | [x] | Stores address for futex-wake on thread exit |
| ulibc `pthread.h` | [x] | `pthread_create`, `pthread_join`, `pthread_exit`, `pthread_self` |
| Per-thread errno | [x] | Via `set_thread_area` + TLS |
| Futex | [x] | `FUTEX_WAIT`/`FUTEX_WAKE` with 32-entry global waiter table |

## 11b. Asynchronous I/O

| Feature | Status | Notes |
|---------|--------|-------|
| `aio_read` | [x] | Asynchronous file read (synchronous implementation) |
| `aio_write` | [x] | Asynchronous file write (synchronous implementation) |
| `aio_error` | [x] | Check completion status of aio operation |
| `aio_return` | [x] | Get return value of completed aio operation |
| `aio_suspend` | [x] | Wait for aio completion (no-op, operations complete synchronously) |

## 11c. Filesystem Operations (Advanced)

| Feature | Status | Notes |
|---------|--------|-------|
| `pivot_root` | [x] | Swap root filesystem; mounts old root at specified path |
| LZ4 initrd decompression | [x] | LZ4 frame decompression for compressed initrd images (`src/kernel/lz4.c`) |
| USTAR initrd format | [x] | `tools/mkinitrd.c` produces standard USTAR archives; kernel parses 512-byte USTAR headers |

## 12. Dynamic Linking

| Feature | Status | Notes |
|---------|--------|-------|
| `ET_DYN` ELF support | [x] | Kernel ELF loader accepts position-independent executables |
| `PT_INTERP` detection | [x] | Kernel reads interpreter path from ELF |
| Interpreter loading | [x] | `elf32_load_interp` loads ld.so at `INTERP_BASE=0x40000000` |
| ELF auxiliary vector types | [x] | `AT_PHDR`, `AT_PHENT`, `AT_PHNUM`, `AT_ENTRY`, `AT_BASE`, `AT_PAGESZ` defined |
| ELF relocation types | [x] | `R_386_RELATIVE`, `R_386_32`, `R_386_GLOB_DAT`, `R_386_JMP_SLOT` defined |
| `Elf32_Dyn`/`Elf32_Rel`/`Elf32_Sym` | [x] | Full dynamic section structures in `elf.h` |
| Userspace `ld.so` | [x] | Functional dynamic linker with auxv parsing; jumps to real entry via AT_ENTRY |
| Shared libraries (.so) | [x] | `dlopen`/`dlsym`/`dlclose` syscalls for runtime shared library loading |
| PLT/GOT support | [x] | Kernel-side eager relocation of `R_386_JMP_SLOT`; auxv (AT_ENTRY/AT_BASE) passed on user stack |

## 13. Userland

| Feature | Status | Notes |
|---------|--------|-------|
| ELF32 loader | [x] | Secure with W^X + ASLR; supports `ET_EXEC` + `ET_DYN` + `PT_INTERP` |
| `/sbin/fulltest` (smoke tests) | [x] | Comprehensive test suite (102 checks: file I/O, signals, memory, IPC, devices, procfs, networking, epoll, epollet, inotify, aio, nanosleep, CoW fork, readv/writev, fsync, flock, posix_spawn, TSC precision, gettimeofday, mprotect, getrlimit/setrlimit, uname, LZ4, lazy PLT, execve) |
| `/bin/echo` | [x] | argv/envp test |
| `/bin/sh` | [x] | POSIX sh-compatible shell; builtins, pipes, redirects, `$PATH` search |
| `/bin/cat` | [x] | |
| `/bin/ls` | [x] | Uses `getdents` |
| `/bin/mkdir` | [x] | |
| `/bin/rm` | [x] | |
| `/bin/cp`, `/bin/mv` | [x] | File copy and move |
| `/bin/touch`, `/bin/ln` | [x] | Create files, hard/symbolic links |
| `/bin/head`, `/bin/tail` | [x] | Display first/last lines |
| `/bin/wc`, `/bin/sort`, `/bin/uniq`, `/bin/cut` | [x] | Text processing utilities |
| `/bin/grep` | [x] | Pattern matching with `-v`/`-c`/`-n` flags |
| `/bin/sed`, `/bin/awk` | [x] | Stream editor and pattern processing |
| `/bin/find`, `/bin/which` | [x] | File search and command lookup |
| `/bin/chmod`, `/bin/chown`, `/bin/chgrp` | [x] | Permission management |
| `/bin/mount`, `/bin/umount` | [x] | Filesystem mount/unmount |
| `/bin/ps`, `/bin/top`, `/bin/kill` | [x] | Process management |
| `/bin/df`, `/bin/du`, `/bin/free` | [x] | Disk and memory usage |
| `/bin/date`, `/bin/hostname`, `/bin/uptime`, `/bin/uname` | [x] | System information |
| `/bin/env`, `/bin/printenv`, `/bin/id` | [x] | Environment and identity |
| `/bin/tee`, `/bin/dd`, `/bin/tr` | [x] | I/O utilities |
| `/bin/basename`, `/bin/dirname`, `/bin/pwd`, `/bin/stat` | [x] | Path and file info |
| `/bin/sleep`, `/bin/clear`, `/bin/rmdir`, `/bin/dmesg`, `/bin/who` | [x] | Misc utilities |
| `/sbin/init` | [x] | SysV-like init process (inittab, runlevels, respawn) |
| `/bin/pie_test` | [x] | PIE/shared library test binary |
| `/bin/doom.elf` | [x] | DOOM (doomgeneric port) running on `/dev/fb0` + `/dev/kbd` |
| `/lib/ld.so` | [x] | Dynamic linker with auxv parsing, PLT/GOT eager relocation, `dlopen`/`dlsym`/`dlclose` |
| Minimal libc (ulibc) | [x] | `printf`, `malloc`, `string.h`, `unistd.h`, `errno.h`, `pthread.h`, `signal.h`, `stdio.h`, `stdlib.h`, `ctype.h`, `sys/mman.h`, `sys/ioctl.h`, `time.h`, `math.h`, `assert.h`, `fcntl.h`, `strings.h`, `inttypes.h`, `sys/types.h`, `sys/stat.h`, `sys/times.h`, `sys/uio.h`, `linux/futex.h` |
| `$PATH` search | [x] | Shell resolves commands via `$PATH` |

## 14. Scheduler

| Feature | Status | Notes |
|---------|--------|-------|
| O(1) bitmap scheduler | [x] | Bitmap + active/expired arrays, 32 priority levels |
| Decay-based priority | [x] | Priority decay on time slice exhaustion; boost on sleep wake |
| Per-process CPU time accounting | [x] | `utime`/`stime` fields incremented per scheduler tick |
| Per-CPU runqueues | [x] | Per-CPU load counters with atomics, least-loaded CPU query |

## 14b. Synchronization (Kernel)

| Feature | Status | Notes |
|---------|--------|-------|
| VMM spinlock | [x] | `vmm_kernel_lock` protects page table operations for SMP safety |
| `vmm_find_free_area()` | [x] | Scans user VA space for free holes; used by mmap without hint |
| Spinlock debug | [x] | Name field, CPU ID tracking, nesting counter for deadlock detection |

---

## Implementation Progress

### All 31 planned tasks completed βœ… + 60 additional features (91 total)

**High Priority (8/8):**
1. ~~`raise()` em ulibc~~ βœ…
2. ~~`fsync`/`fdatasync` no-op stubs~~ βœ…
3. ~~`O_APPEND` support in `write()` + `fcntl`~~ βœ…
4. ~~`sigpending()` syscall~~ βœ…
5. ~~`pread`/`pwrite` syscalls~~ βœ…
6. ~~`access()` syscall~~ βœ…
7. ~~`umask()` syscall~~ βœ…
8. ~~`setuid`/`setgid` syscalls~~ βœ…

**Medium Priority (13/13):**
9. ~~`truncate`/`ftruncate`~~ βœ…
10. ~~`sigsuspend()`~~ βœ…
11. ~~`$PATH` search in shell~~ βœ…
12. ~~User-Buffered I/O (`stdio.h` em ulibc)~~ βœ…
13. ~~`realpath()` em ulibc~~ βœ…
14. ~~`readv`/`writev` syscalls~~ βœ…
15. ~~RTC driver + `CLOCK_REALTIME`~~ βœ…
16. ~~`alarm()` syscall + `SIGALRM` timer~~ βœ…
17. ~~Guard pages (32KB stack + unmapped guard)~~ βœ…
18. ~~PMM contiguous block alloc~~ βœ…
19. ~~Hard links (`diskfs_link()` with shared storage)~~ βœ…
20. ~~`times()` syscall β€” CPU time accounting~~ βœ…
21. ~~Futex β€” `FUTEX_WAIT`/`FUTEX_WAKE`~~ βœ…

**Low Priority (10/10):**
22. ~~`sigaltstack`~~ βœ…
23. ~~File locking (`flock`)~~ βœ…
24. ~~Write-Combining MTRRs~~ βœ…
25. ~~Decay-based scheduler~~ βœ…
26. ~~vDSO shared page~~ βœ…
27. ~~DNS resolver~~ βœ…
28. ~~FAT16 filesystem~~ βœ…
29. ~~Zero-Copy DMA I/O~~ βœ…
30. ~~Userspace `ld.so` stub~~ βœ…
31. ~~ASLR~~ βœ…

**Additional Features (post-31 tasks):**
32. ~~DevFS ↔ TTY/PTY decoupling (`devfs_register_device` API)~~ βœ…
33. ~~VMM arch separation (`src/mm/vmm.c` generic wrappers)~~ βœ…
34. ~~`/dev/fb0` framebuffer device (ioctl + mmap)~~ βœ…
35. ~~`/dev/kbd` raw scancode device~~ βœ…
36. ~~fd-backed `mmap` (file descriptor memory mapping)~~ βœ…
37. ~~Kernel stack guard pages (0xC8000000 region)~~ βœ…
38. ~~uid/gid/euid/egid with VFS permission enforcement~~ βœ…
39. ~~DOOM port (doomgeneric + AdrOS adapter, 450KB doom.elf)~~ βœ…
40. ~~Buddy Allocator heap (replaced doubly-linked-list heap)~~ βœ…
41. ~~lwIP NO_SYS=0 threaded mode (kernel semaphores/mutexes/mailboxes)~~ βœ…
42. ~~kprintf migration (all uart_printβ†’kprintf, 16KB ring buffer, dmesg)~~ βœ…
43. ~~Unified FAT12/16/32 full RW driver (replaced read-only FAT16)~~ βœ…
44. ~~ext2 filesystem full RW~~ βœ…
45. ~~Kernel command line parser (Linux-like: init=, root=, ring3, quiet, /proc/cmdline)~~ βœ…
46. ~~Multi-drive ATA support (4 drives across 2 channels)~~ βœ…
47. ~~IOAPIC level-triggered routing for PCI interrupts~~ βœ…
48. ~~ICMP ping test (kernel-level, verified in smoke test)~~ βœ…
49. ~~SMAP β€” CR4 bit 21~~ βœ…
50. ~~F_GETPIPE_SZ / F_SETPIPE_SZ β€” pipe capacity fcntl~~ βœ…
51. ~~waitid β€” extended wait~~ βœ…
52. ~~sigqueue β€” queued real-time signals~~ βœ…
53. ~~select/poll for regular files~~ βœ…
54. ~~setitimer/getitimer β€” interval timers~~ βœ…
55. ~~posix_spawn β€” efficient process creation~~ βœ…
56. ~~POSIX message queues mq_*~~ βœ…
57. ~~POSIX semaphores sem_*~~ βœ…
58. ~~getaddrinfo / /etc/hosts~~ βœ…
59. ~~DHCP client~~ βœ…
60. ~~E1000 rx_thread scheduling fix~~ βœ…
61. ~~Virtio-blk driver~~ βœ…
62. ~~Full ld.so relocation processing~~ βœ…
63. ~~IPv6 support (lwIP dual-stack)~~ βœ…
64. ~~Shared libraries .so β€” dlopen/dlsym/dlclose~~ βœ…
65. ~~Per-CPU scheduler runqueue infrastructure~~ βœ…
66. ~~Multi-arch ARM64/RISC-V bring-up (QEMU virt boot)~~ βœ…
67. ~~VMM spinlock β€” SMP-safe page table operations~~ βœ…
68. ~~`vmm_find_free_area()` β€” VA space scan for mmap without hint~~ βœ…
69. ~~Spinlock debug β€” name, CPU ID tracking, nesting counter~~ βœ…
70. ~~`epoll` β€” scalable I/O event notification~~ βœ…
71. ~~`inotify` β€” filesystem event monitoring~~ βœ…
72. ~~`sendmsg`/`recvmsg` β€” scatter-gather socket I/O~~ βœ…
73. ~~`pivot_root` β€” root filesystem swap syscall~~ βœ…
74. ~~Shared library lazy binding β€” functional ld.so with auxv, PLT/GOT~~ βœ…
75. ~~`aio_*` β€” POSIX asynchronous I/O~~ βœ…
76. ~~`gettimeofday` syscall~~ βœ…
77. ~~`mprotect` memory protection syscall~~ βœ…
78. ~~`getrlimit`/`setrlimit` resource limits~~ βœ…
79. ~~`uname` system info syscall~~ βœ…
80. ~~`setsockopt`/`getsockopt`/`shutdown`/`getpeername`/`getsockname` socket ops~~ βœ…
81. ~~`getrusage` resource usage~~ βœ…
82. ~~LZ4 initrd decompression~~ βœ…
83. ~~`EPOLLET` edge-triggered epoll~~ βœ…
84. ~~PLT/GOT lazy binding in userspace ld.so~~ βœ…
85. ~~MIPS32 bring-up (QEMU Malta boot + UART)~~ βœ…
86. ~~SysV `/sbin/init` (inittab, runlevels, respawn)~~ βœ…
87. ~~50+ userland POSIX utilities (cp, mv, sed, awk, grep, find, etc.)~~ βœ…
88. ~~Host utility test harness (68 cross-platform tests)~~ βœ…
89. ~~Native toolchain (GCC 13.2 + Binutils 2.42, Canadian cross for i686-adros)~~ βœ…
90. ~~`mount` syscall β€” runtime filesystem mounting~~ βœ…
91. ~~USTAR InitRD format with LZ4 Frame compression~~ βœ…

---

## Remaining Work

All previously identified gaps have been implemented. Rump Kernel integration prerequisites (condition variables, TSC nanosecond clock, IRQ chaining) are complete, and the `rumpuser` hypercall scaffold is in place.

Potential future enhancements:

| Area | Description |
|------|-------------|
| **Rump Kernel Phase 2** | Thread/sync hypercalls (`rumpuser_thread_create`, `rumpuser_mutex_*`, `rumpuser_cv_*`) |
| **Rump Kernel Phase 4** | File/block I/O hypercalls for rump filesystem drivers |
| **Full SMP scheduling** | Move processes to AP runqueues; per-CPU dispatching (infrastructure in place) |
| **ARM64/RISC-V/MIPS subsystems** | PMM, VMM, scheduler, syscalls for non-x86 |
| **Intel HDA audio** | DMA ring buffer audio driver |
| ~~**USTAR initrd format**~~ | βœ… Implemented β€” USTAR + LZ4 Frame format |