ke/sched: add pin helpers

This commit is contained in:
Loïc Grégoire
2026-08-20 21:33:22 -04:00
parent f6f20599ba
commit 07b3893859
4 changed files with 20 additions and 7 deletions
+4 -6
View File
@@ -130,9 +130,8 @@ const Pool = struct {
td.kern.nice = -ke.Priority.nice_max;
if (cpu != null) {
td.kern.last_cpu = cpu;
td.kern.pinned = true;
if (cpu) |c| {
ke.sched.pin_on(&td.kern, c);
}
ke.sched.enqueue(&td.kern);
@@ -181,9 +180,8 @@ const Pool = struct {
@ptrFromInt(ctx.value),
);
if (cpu != null) {
td.kern.last_cpu = cpu;
td.kern.pinned = true;
if (cpu) |c| {
ke.sched.pin_on(&td.kern, c);
}
ke.sched.enqueue(&td.kern);
+2
View File
@@ -58,6 +58,8 @@ pub const sched = struct {
pub const unblock = p.sched.unblock;
pub const late_init = p.sched.late_init;
pub const yield = p.sched.yield;
pub const pin = p.sched.pin;
pub const pin_on = p.sched.pin_on;
};
pub const timer = struct {
+13
View File
@@ -1405,6 +1405,19 @@ pub fn update_priority_locked(td: *ke.Thread, new_prio: u8) void {
// XXX: Handle Selected threads so that they are placed properly?
}
pub fn pin(td: *ke.Thread) void {
const ipl = td.lock.acquire();
td.pinned = true;
td.lock.release(ipl);
}
pub fn pin_on(td: *ke.Thread, cpu: u32) void {
const ipl = td.lock.acquire();
td.last_cpu = cpu;
td.pinned = true;
td.lock.release(ipl);
}
fn find_most_loaded(exclude: ?*ke.CpuMask, steal: bool) ?u32 {
var most: ?u32 = null;
var most_load: usize = 0;
+1 -1
View File
@@ -47,7 +47,7 @@ fn make_thread(
td.init(stack, size, .IdleThread, entrypoint, null);
td.pinned = true;
ke.sched.pin(td);
return td;
}