scheduler: Make sleep cancellable

This commit is contained in:
2026-06-04 17:44:02 +02:00
parent 1c1cc1041a
commit 445fd2fd7f
3 changed files with 90 additions and 45 deletions
+2 -1
View File
@@ -316,13 +316,14 @@ fn taskReturned() callconv(.c) noreturn {
}
// Called by the current task to return control to the scheduler
pub fn sleep(self: *Scheduler, delta_us: u64) void {
pub fn sleep(self: *Scheduler, delta_us: u64) !void {
const current = self.findTaskByID(self.current_id.?).?;
current.state = .blocked;
current.wakeup_time = self.current_time + delta_us;
current.wakeup_tasks = null;
current.wakeup_futex = null;
contextSwitch(&current.regs, &self.regs);
try self.checkCancel();
}
pub fn futexWait(self: *Scheduler, ptr: *const u32, expected: u32) void {