ke/mutex: do TTAS spin

This is better to do than `pause`-ing in a CAS loop.
This commit is contained in:
Loïc Grégoire
2026-07-18 16:08:34 -04:00
parent 89259141bb
commit fddd9865f7
+5 -1
View File
@@ -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;
}