Commit Graph

15 Commits

Author SHA1 Message Date
Matthew Leach
5ebfc29cd2 sched: introduce Work as the unified scheduleable unit
Refactor the scheduler so all scheduleable work is wrapped in Arc<Work>,
replacing the previous per-CPU wait_q design where sleeping tasks were
bound to a specific CPU. Wakers now hold direct Arc<Work> references and
can re-enqueue tasks on any CPU upon wakeup.

Key changes:

- Add Work struct wrapping OwnedTask with an AtomicTaskState and
  scheduler metadata (SchedulerData), replacing the old SchedulableTask.
  Remove Task::state (Arc<SpinLock<TaskState>>). Work::state is now the
  single source of truth for task state.

- Rewrite the run queue using BinaryHeap-based eligible/ineligible split
  (EEVDF) with a dedicated VClock, replacing the BTreeMap linear scan.
  Extract vclock into its own module.

- Rewrite wakers to hold Arc<Work> directly instead of looking up tasks
  by TaskDescriptor from TASK_LIST.

- Replace lock-based sleep transitions in uspc_ret with atomic CAS
  (try_sleep_current) that correctly detects concurrent Woken state.

- Simplify least-tasked-CPU metric to use only run-queue weight, since
  sleeping tasks are no longer bound to any CPU.

- Add current_work() accessor.
2026-03-12 10:53:22 +00:00
Ashwin Naren
d7ad7b76dc fix clocks not actually updating within time slice 2026-01-25 10:50:02 -08:00
Ashwin Naren
c5a0976a73 track stime and utime
Tracks stime and utime for processes and tasks. Reports the times through procfs and `sys_clock_gettime`.
2026-01-25 10:50:02 -08:00
Ashwin Naren
aa5a9c7b79 fix typos 2026-01-23 01:26:04 -08:00
Ashwin Naren
92efb4cee7 enforce semicolon_if_nothing_returned and uninlined_format_args 2026-01-23 01:26:04 -08:00
Matthew Leach
71d120ebe7 thread_group: deliver_signal: ensure signal delivery
If all tasks within a thread group are sleeping when a signal is
delivered, wake at least one task to action the signal.
2026-01-17 10:21:17 +00:00
Matthew Leach
abbc8261c5 kill: awake sleepy tasks on SIGKILL
If a SIGKILL has been received, ensure all sleepy tasks are set to
runnable so that they can action the signal.
2026-01-11 19:23:47 -08:00
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
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
Ashwin Naren
2383bf99bb support stat in procfs 2026-01-01 16:44:55 -08: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
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
Matthew Leach
62a804e456 fmt: cleanup after rustfmt 2025-11-21 23:03:14 +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