# ahrightos-process
`ahrightos-process` contains the portable process-management primitives used by
the AhRightOS teaching kernel: PID allocation, saved contexts, process control
blocks, process states, and the round-robin scheduler.
The crate is `no_std` outside tests and intentionally avoids QEMU-specific
entry code, so students can unit-test process behavior on the host before
booting the full kernel.
`ProcessContext` publishes layout constants used by the RISC-V context-switch
assembly, and the crate tests assert that the ABI offsets stay stable.
## Lifecycle contracts
- Parent child lists are de-duplicated so repeated bookkeeping cannot create
phantom children.
- `RoundRobinScheduler::find_zombie_child` is the reap path used by `wait`.
- `has_living_children` intentionally excludes zombies: a zombie is reapable
state, not a runnable/blocking child. This prevents `wait` from blocking after
all remaining children have exited.
- Kernel ELF loading now rejects non-`ET_EXEC` files and entry points outside
`PT_LOAD` segments; AhRightOS does not claim a full Linux `execve` model yet.
```mermaid
flowchart LR
Kernel[ahrightos-kernel] --> Process[ahrightos-process]
Process --> PID[ProcessId]
Process --> PCB[ProcessControlBlock]
Process --> Context[ProcessContext]
Process --> Scheduler[RoundRobinScheduler]
```