Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3dfd0fd
Report arm intersections
Nadrieril Mar 17, 2024
e4487ad
Improve the `WitnessPat: Debug` impl
Nadrieril Mar 4, 2024
d697dd4
Add a crate-custom test harness
Nadrieril Mar 4, 2024
a2c74b8
SeqCst->Relaxed in doc examples.
m-ou-se Mar 19, 2024
5e4cc6f
SeqCst->Relaxed in panic_unwind/emcc.
m-ou-se Mar 19, 2024
bf3debe
SeqCst->Relaxed for proc_macro bridge counter.
m-ou-se Mar 19, 2024
904fef0
SeqCst->{Release,Acquire} for alloc error hook.
m-ou-se Mar 19, 2024
9f25a04
SeqCst->Relaxed for FIRST_PANIC.
m-ou-se Mar 19, 2024
eb96698
SeqCst->{Release,Acquire} in xous mutex.
m-ou-se Mar 19, 2024
516684c
Use less restricted memory ordering in thread_parking::pthread.
m-ou-se Mar 19, 2024
e43aef0
SeqCst->{Release,Acquire} in sys_common::thread_local_key.
m-ou-se Mar 19, 2024
46bb073
SeqCst->{Release,Acquire} for wasm DropLock.
m-ou-se Mar 19, 2024
60ad490
SeqCst->Relaxed in pal::windows::pipe.
m-ou-se Mar 19, 2024
69a4d77
SeqCst->{Release,Acquire} for xous DropLock.
m-ou-se Mar 19, 2024
5a594f7
SeqCst->Relaxed for xous set_nonblocking.
m-ou-se Mar 19, 2024
75a5196
use more accurate terminology
tshepang Mar 19, 2024
70206f0
coverage: Regression test for ICE triggered by self-loops
Zalathar Mar 20, 2024
85bec7a
coverage: Remove incorrect assertions from counter allocation
Zalathar Mar 20, 2024
2f21e4f
coverage: Tidy imports in `rustc_mir_transform::coverage::counters`
Zalathar Mar 20, 2024
92f668c
Add usize::MAX arg tests for Vec
workingjubilee Mar 20, 2024
8b519f9
Use less restricted memory ordering in xous::thread_local_key.
m-ou-se Mar 19, 2024
b45a725
SeqCst->Relaxed in std::net::test.
m-ou-se Mar 19, 2024
acddc55
SeqCst->Relaxed in thread local test.
m-ou-se Mar 19, 2024
3462175
SeqCst->Relaxed in condvar test.
m-ou-se Mar 19, 2024
2fca27c
Add bare metal riscv32 target.
royb3 Mar 18, 2024
98e6655
Rename `hir::Let` into `hir::LetExpr`
GuillaumeGomez Mar 20, 2024
a845246
Ignore paths from expansion in `unused_qualifications`
Alexendoo Mar 15, 2024
19e0ea4
make `type_flags(ReError) & HAS_ERROR`
aliemjay Mar 19, 2024
0dc006b
register opaques that reference errors
aliemjay Mar 20, 2024
352587a
compiletest: mir_dump_dir.as_path() -> &mir_dump_dir
Enselic Mar 20, 2024
c3cc6c1
compiletest: Introduce remove_and_create_dir_all() helper
Enselic Mar 20, 2024
f343870
Rollup merge of #122545 - Alexendoo:unused-qualifications, r=petroche…
matthiaskrgr Mar 20, 2024
da76c0b
Rollup merge of #122644 - Nadrieril:complexity-tests, r=compiler-errors
matthiaskrgr Mar 20, 2024
6af9745
Rollup merge of #122696 - royb3:riscv32ima, r=petrochenkov
matthiaskrgr Mar 20, 2024
ac0d75e
Rollup merge of #122729 - m-ou-se:relax, r=Amanieu
matthiaskrgr Mar 20, 2024
f927a08
Rollup merge of #122740 - tshepang:patch-1, r=clubby789
matthiaskrgr Mar 20, 2024
79915ac
Rollup merge of #122749 - aliemjay:region-err, r=compiler-errors
matthiaskrgr Mar 20, 2024
30a4e0e
Rollup merge of #122764 - Zalathar:loopy, r=oli-obk
matthiaskrgr Mar 20, 2024
112f7b0
Rollup merge of #122765 - workingjubilee:test-for-vec-handling-usize-…
matthiaskrgr Mar 20, 2024
1ea3b75
Rollup merge of #122776 - GuillaumeGomez:rename-hir-let, r=oli-obk
matthiaskrgr Mar 20, 2024
1000526
Rollup merge of #122786 - Enselic:remove_and_create_dir_all, r=onur-o…
matthiaskrgr Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SeqCst->{Release,Acquire} in xous mutex.
No need for SeqCst. Release+Acquire is the right memory ordering for a
mutex.
  • Loading branch information
m-ou-se committed Mar 19, 2024
commit eb966983f2814b80d6bb526b53557dd32b1621c0
11 changes: 7 additions & 4 deletions library/std/src/sys/sync/mutex/xous.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
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};
use crate::sync::atomic::{
AtomicBool, AtomicUsize,
Ordering::{Acquire, Relaxed, Release},
};

pub struct Mutex {
/// The "locked" value indicates how many threads are waiting on this
Expand Down Expand Up @@ -68,7 +71,7 @@ impl Mutex {

#[inline]
pub unsafe fn unlock(&self) {
let prev = self.locked.fetch_sub(1, SeqCst);
let prev = self.locked.fetch_sub(1, Release);

// If the previous value was 1, then this was a "fast path" unlock, so no
// need to involve the Ticktimer server
Expand All @@ -89,12 +92,12 @@ impl Mutex {

#[inline]
pub unsafe fn try_lock(&self) -> bool {
self.locked.compare_exchange(0, 1, SeqCst, SeqCst).is_ok()
self.locked.compare_exchange(0, 1, Acquire, Relaxed).is_ok()
}

#[inline]
pub unsafe fn try_lock_or_poison(&self) -> bool {
self.locked.fetch_add(1, SeqCst) == 0
self.locked.fetch_add(1, Acquire) == 0
}
}

Expand Down