diff --git a/src/kern/mutex.zig b/src/kern/mutex.zig index cbea8a3..8d82d99 100644 --- a/src/kern/mutex.zig +++ b/src/kern/mutex.zig @@ -31,11 +31,15 @@ pub const Mutex = struct { // Fast path: Try to acquire without a turnstile by spinning a bit. for (0..optimistic_spins) |_| { - if (m.owner.cmpxchgWeak(null, curtd, .acquire, .monotonic) != null) { + if (m.owner.load(.monotonic) != null) { std.atomic.spinLoopHint(); continue; } + if (m.owner.cmpxchgWeak(null, curtd, .acquire, .monotonic) != null) { + continue; + } + ke.ipl.lower(ipl); return; }