ke: make getting the current thread atomic

This commit is contained in:
Loïc Grégoire
2026-10-23 23:47:23 -04:00
parent 0a843157c2
commit 76147556a3
10 changed files with 38 additions and 24 deletions
+3 -5
View File
@@ -32,9 +32,7 @@ pub const Mutex = struct {
}
pub fn acquire(m: *Mutex) void {
const ipl = ke.ipl.raise(.Dispatch);
const curtd = kep.sched.percpu.local().current_thread orelse
unreachable;
const curtd = ke.thread.current();
if (config.warden) {
kep.warden.check(m.wd, .Lock);
@@ -54,7 +52,6 @@ pub const Mutex = struct {
);
if (cur_owner == null) {
ke.ipl.lower(ipl);
return;
}
@@ -74,10 +71,11 @@ pub const Mutex = struct {
continue;
}
ke.ipl.lower(ipl);
return;
}
const ipl = ke.ipl.raise(.Dispatch);
// Slow path: contended, block on a turnstile.
while (true) {
const ts = kep.turnstile.lookup(m);