diff options
| author | Sean Cross <sean@xobs.io> | 2023-12-29 18:07:53 +0800 |
|---|---|---|
| committer | Sean Cross <sean@xobs.io> | 2024-01-13 09:13:56 -0800 |
| commit | b5c1c47990b7a32dbc0fd93f4c807b565814f1c2 (patch) | |
| tree | 114827ba11fa5edbc1a34fb4cd47aa4a90c43a8a /library/std/src | |
| parent | f732d2bfe293349bd3a7b7d8a2211a8058d3fb31 (diff) | |
| download | rust-b5c1c47990b7a32dbc0fd93f4c807b565814f1c2.tar.gz rust-b5c1c47990b7a32dbc0fd93f4c807b565814f1c2.zip | |
std: xous: use blocking_scalars for mutex unlock
Use blocking scalars when unlocking a mutex. This ensures that mutexes are unlocked immediately rather than dangling. Signed-off-by: Sean Cross <sean@xobs.io>
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/pal/xous/locks/mutex.rs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/library/std/src/sys/pal/xous/locks/mutex.rs b/library/std/src/sys/pal/xous/locks/mutex.rs index ea51776d54e..a8c9518ff0b 100644 --- a/library/std/src/sys/pal/xous/locks/mutex.rs +++ b/library/std/src/sys/pal/xous/locks/mutex.rs @@ -1,5 +1,5 @@ -use crate::os::xous::ffi::{blocking_scalar, do_yield, scalar}; -use crate::os::xous::services::ticktimer_server; +use crate::os::xous::ffi::{blocking_scalar, do_yield}; +use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering::Relaxed, Ordering::SeqCst}; pub struct Mutex { @@ -29,7 +29,7 @@ impl Mutex { } fn index(&self) -> usize { - self as *const Mutex as usize + core::ptr::from_ref(self).addr() } #[inline] @@ -83,11 +83,8 @@ impl Mutex { } // Unblock one thread that is waiting on this message. - scalar( - ticktimer_server(), - crate::os::xous::services::TicktimerScalar::UnlockMutex(self.index()).into(), - ) - .expect("failure to send UnlockMutex command"); + blocking_scalar(ticktimer_server(), TicktimerScalar::UnlockMutex(self.index()).into()) + .expect("failure to send UnlockMutex command"); } #[inline] @@ -106,11 +103,8 @@ impl Drop for Mutex { // If there was Mutex contention, then we involved the ticktimer. Free // the resources associated with this Mutex as it is deallocated. if self.contended.load(Relaxed) { - scalar( - ticktimer_server(), - crate::os::xous::services::TicktimerScalar::FreeMutex(self.index()).into(), - ) - .ok(); + blocking_scalar(ticktimer_server(), TicktimerScalar::FreeMutex(self.index()).into()) + .ok(); } } } |
