Make the `Tid` globally unique, rather than `Tgid` creating a new number
space. This allows ptrace to differentiate between threads when using
`-f` on a program which spawns threads.
Replace `CUR_TASK_PTR` with `ProcessCtx`. This allows differentiation
between functions that access process context (take in `ProcessCtx` as a
parameter) and those that don't.
When creating a new class of scheduleable tasks (softirqs, kthreads),
this ensure that those functions cannot call context-sensitive
functions.
Replace the single `SmallRng` with a proper two-layer RNG architecture:
- Global BLAKE2s-256 entropy pool that accumulates entropy and gates
seed extraction behind a 256-bit threshold.
- Per-CPU ChaCha20Rng instances that are lazily seeded from the pool on
first use and periodically reseed every 1 MB by XOR-ing a fresh BLAKE2
extract with 32 bytes of their own output.
The /dev/random chardev uses fill_random_bytes directly instead of
routing through the syscall layer.
Rework uname to avoid hardcoded datetime and add unit tests
Restructure `uname` so that:
- there is an internal function that does the main logic and can be tested by unit tests
- Generate an env var in build.rs that is the actual build datetime timestamp
- Avoid hardcoded date in the version string
- Use the timestamp in the building of `uname` response, so the data is the actual build time
- add a simple unit test for the sysname field
- add more complex test for the version field that checks the date formatting (not exhaustively)
NOTE: The build timestamp can be used by any other function, syscall or part of the code if required.
This commit refactors the core process representation to decouple
"Identity/Resources" from "Execution/Scheduling". Previously, a
monolithic `Task` struct wrapped in `Arc<SpinLock<>>` caused lock
contention during hot scheduling paths and conflated shared state with
CPU-local state.
The `Task` struct has been split into:
1. `Task` (Shared): Holds process-wide resources (VM, FileTable,
Credentials). Managed via `Arc` and internal fine-grained locking.
2. `OwnedTask` (Private): Holds execution state (Context, v_runtime,
signal mask). Strictly owned by a specific CPU (via the Scheduler) and
accessed lock-free.
Key changes:
* Scheduler:
chedState` now owns tasks via `Box<OwnedTask>`.
- Transitions between `run_queue` and `running_task` involve strictly
moving ownership of the Box, ensuring pointer stability.
- The EEVDF comparison logic now explicitly handles comparisons
between the queued candidates and the currently running task (which is
not in the queue).
* Current Task Access:
- `current()` now returns a `CurrentTaskGuard` which:
1. Disables preemption (preventing context switches while holding
the reference).
2. Performs a runtime borrow check (panic on double-mutable borrow).
3. Dereferences a cached Per-CPU raw pointer for O(1) access.
libc bringup checks the version of the kernel and it appears as though
it's not happy with `0.1.0`:
```
FATAL: kernel too old
```
For now, fudge the version to keep libc happy.