mirror of
https://github.com/rdmsr/zag.git
synced 2026-11-02 08:08:21 +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.
|
// Fast path: Try to acquire without a turnstile by spinning a bit.
|
||||||
for (0..optimistic_spins) |_| {
|
for (0..optimistic_spins) |_| {
|
||||||
if (m.owner.cmpxchgWeak(null, curtd, .acquire, .monotonic) != null) {
|
if (m.owner.load(.monotonic) != null) {
|
||||||
std.atomic.spinLoopHint();
|
std.atomic.spinLoopHint();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m.owner.cmpxchgWeak(null, curtd, .acquire, .monotonic) != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ke.ipl.lower(ipl);
|
ke.ipl.lower(ipl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user