mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
ke/mutex: do TTAS spin
This is better to do than `pause`-ing in a CAS loop.
This commit is contained in:
+5
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user