mirror of
https://github.com/rdmsr/zag.git
synced 2026-11-02 16:18:22 +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;
|
td.kern.nice = -ke.Priority.nice_max;
|
||||||
|
|
||||||
if (cpu != null) {
|
if (cpu) |c| {
|
||||||
td.kern.last_cpu = cpu;
|
ke.sched.pin_on(&td.kern, c);
|
||||||
td.kern.pinned = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ke.sched.enqueue(&td.kern);
|
ke.sched.enqueue(&td.kern);
|
||||||
@@ -181,9 +180,8 @@ const Pool = struct {
|
|||||||
@ptrFromInt(ctx.value),
|
@ptrFromInt(ctx.value),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (cpu != null) {
|
if (cpu) |c| {
|
||||||
td.kern.last_cpu = cpu;
|
ke.sched.pin_on(&td.kern, c);
|
||||||
td.kern.pinned = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ke.sched.enqueue(&td.kern);
|
ke.sched.enqueue(&td.kern);
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ pub const sched = struct {
|
|||||||
pub const unblock = p.sched.unblock;
|
pub const unblock = p.sched.unblock;
|
||||||
pub const late_init = p.sched.late_init;
|
pub const late_init = p.sched.late_init;
|
||||||
pub const yield = p.sched.yield;
|
pub const yield = p.sched.yield;
|
||||||
|
pub const pin = p.sched.pin;
|
||||||
|
pub const pin_on = p.sched.pin_on;
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const timer = struct {
|
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?
|
// 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 {
|
fn find_most_loaded(exclude: ?*ke.CpuMask, steal: bool) ?u32 {
|
||||||
var most: ?u32 = null;
|
var most: ?u32 = null;
|
||||||
var most_load: usize = 0;
|
var most_load: usize = 0;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ fn make_thread(
|
|||||||
|
|
||||||
td.init(stack, size, .IdleThread, entrypoint, null);
|
td.init(stack, size, .IdleThread, entrypoint, null);
|
||||||
|
|
||||||
td.pinned = true;
|
ke.sched.pin(td);
|
||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user