mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
ke/sched: add pin helpers
This commit is contained in:
+4
-6
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -47,7 +47,7 @@ fn make_thread(
|
||||
|
||||
td.init(stack, size, .IdleThread, entrypoint, null);
|
||||
|
||||
td.pinned = true;
|
||||
ke.sched.pin(td);
|
||||
return td;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user