summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/base/mutex-inl.h4
-rw-r--r--runtime/base/mutex.cc6
2 files changed, 5 insertions, 5 deletions
diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h
index 51ca274cbb..74db31256b 100644
--- a/runtime/base/mutex-inl.h
+++ b/runtime/base/mutex-inl.h
@@ -193,8 +193,8 @@ inline void ReaderWriterMutex::SharedUnlock(Thread* self) {
// a status bit into the state on contention.
done = state_.CompareAndSetWeakSequentiallyConsistent(cur_state, cur_state - 1);
if (done && (cur_state - 1) == 0) { // Weak CAS may fail spuriously.
- if (num_pending_writers_.load(std::memory_order_relaxed) > 0 ||
- num_pending_readers_.load(std::memory_order_relaxed) > 0) {
+ if (num_pending_writers_.load(std::memory_order_seq_cst) > 0 ||
+ num_pending_readers_.load(std::memory_order_seq_cst) > 0) {
// Wake any exclusive waiters as there are now no readers.
futex(state_.Address(), FUTEX_WAKE, -1, nullptr, nullptr, 0);
}
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index dd58d75a32..7b888b18d9 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -553,7 +553,7 @@ void Mutex::ExclusiveUnlock(Thread* self) {
done = state_.CompareAndSetWeakSequentiallyConsistent(cur_state, 0 /* new state */);
if (LIKELY(done)) { // Spurious fail?
// Wake a contender.
- if (UNLIKELY(num_contenders_.load(std::memory_order_relaxed) > 0)) {
+ if (UNLIKELY(num_contenders_.load(std::memory_order_seq_cst) > 0)) {
futex(state_.Address(), FUTEX_WAKE, 1, nullptr, nullptr, 0);
}
}
@@ -690,8 +690,8 @@ void ReaderWriterMutex::ExclusiveUnlock(Thread* self) {
done = state_.CompareAndSetWeakSequentiallyConsistent(-1 /* cur_state*/, 0 /* new state */);
if (LIKELY(done)) { // Weak CAS may fail spuriously.
// Wake any waiters.
- if (UNLIKELY(num_pending_readers_.load(std::memory_order_relaxed) > 0 ||
- num_pending_writers_.load(std::memory_order_relaxed) > 0)) {
+ if (UNLIKELY(num_pending_readers_.load(std::memory_order_seq_cst) > 0 ||
+ num_pending_writers_.load(std::memory_order_seq_cst) > 0)) {
futex(state_.Address(), FUTEX_WAKE, -1, nullptr, nullptr, 0);
}
}