Skip to content

Commit 69a4d77

Browse files
committed
SeqCst->{Release,Acquire} for xous DropLock.
SeqCst is unnecessary. Release+Acquire is the right ordering for a mutex.
1 parent 60ad490 commit 69a4d77

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/std/src/sys/pal/xous/alloc.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ unsafe impl GlobalAlloc for System {
4646
}
4747

4848
mod lock {
49-
use crate::sync::atomic::{AtomicI32, Ordering::SeqCst};
49+
use crate::sync::atomic::{
50+
AtomicI32,
51+
Ordering::{Acquire, Release},
52+
};
5053

5154
static LOCKED: AtomicI32 = AtomicI32::new(0);
5255

5356
pub struct DropLock;
5457

5558
pub fn lock() -> DropLock {
5659
loop {
57-
if LOCKED.swap(1, SeqCst) == 0 {
60+
if LOCKED.swap(1, Acquire) == 0 {
5861
return DropLock;
5962
}
6063
crate::os::xous::ffi::do_yield();
@@ -63,7 +66,7 @@ mod lock {
6366

6467
impl Drop for DropLock {
6568
fn drop(&mut self) {
66-
let r = LOCKED.swap(0, SeqCst);
69+
let r = LOCKED.swap(0, Release);
6770
debug_assert_eq!(r, 1);
6871
}
6972
}

0 commit comments

Comments
 (0)