Commit Graph

13 Commits

Author SHA1 Message Date
Matthew Leach
1d79d6b2df process: refactor signal handling and fix action table sharing
This commit refactors the signal handling subsystem to address a bug in
process creation and to improve the separation of concerns between
signal delivery and signal disposition.

1. Fix Action Table Sharing:
Previously, the signal action table was wrapped in an `Arc`, causing
forked child processes to inadvertently share signal dispositions with
the parent. `SignalActionState` now contains a direct `SigActionSet` and
implements Clone, ensuring that processes receive a private copy of the
action table upon fork/clone.

2. Decouple Signal Selection from Execution:
The logic for selecting a pending signal has been moved from the
disposition state into a new `take_signal` method on `OwnedTask`. This
decouples the "taking" of a signal (respecting masks and priorities)
from the "actioning" of that signal. This is a prerequisite for
implementing ptrace.

3. Various cleanup bits:
- Renamed `SignalState` to `SignalActionState` to more accurately
  reflect that it manages signal dispositions.
- Removed the `pending` signal set out of the action state and directly
  into the `ThreadGroup` and `OwnedTask`.
- Renamed `set_pending` to `set_signal` for consistency.
- Simplified the signal delivery loop in `dispatch_userspace_task`
  using the new `take_signal` API.
2026-01-09 06:49:48 +00:00
Matthew Leach
e8d6c304ae syscalls: wait4: implement WNOHANG
Implement WNOHANG logic within the sys_wait4 system call. If this is
flag is set, remove the process from the ChildNotifiers set without
waiting.
2026-01-08 15:29:42 -08:00
Matthew Leach
57e0aa364c process: task_group: implement pg priority
Currently, each task implements it's own priority value. In Linux, each
thread group (process) has a default process which all tasks in that
group inherit. Tasks can, however, override the default process
priority.

Implement that logic here which also fixes the current compilation error
on master.
2026-01-02 18:16:11 -08:00
Matthew Leach
b8bcbfe91b Merge pull request #116 from hexagonal-sun/implement-ownedtask
process: split `Task` into `Task` (shared) and `OwnedTask` (local)
2026-01-02 17:37:43 +00:00
Ashwin Naren
2383bf99bb support stat in procfs 2026-01-01 16:44:55 -08:00
Matthew Leach
35efecad76 process: split Task into Task (shared) and OwnedTask (local)
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.
2026-01-01 22:54:43 +00:00
Matthew Leach
116a1adbd0 clone: add all tasks to process task list
This prevents a bug where `sys_exit` calls `exit_group` for the thread's
process, even when there are still active threads.
2025-12-28 23:51:51 -08:00
Ashwin Naren
7122429a20 dispatch signals (#85) 2025-12-24 12:54:40 -08:00
Matthew Leach
a7ebe8e214 threading: fix clone to spawn threads
Fix issues identify in `sys_clone` logic to enable basic threading.
2025-12-21 16:13:15 -08:00
Ashwin Naren
661f368334 implement sys_kill 2025-12-01 19:55:41 +00:00
Matthew Leach
6c804ce2a7 thread_group: builder: remove unused function
Remove unused function `with_umask`.
2025-11-22 12:47:02 +00:00
Matthew Leach
8abda6dd9c syscalls: umask: implement
implement umask(2).
2025-11-21 23:03:14 +00:00
Matthew Leach
ca6fdd0da5 Initial Commit
Initial commit of arm64 bring-up code, kernel core (libkernel) and build
infrastructure.
2025-11-16 20:15:01 +00:00