fix DOWNGRADED bit unpreserved

Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
This commit is contained in:
Connor Tsui 2024-11-16 12:22:35 -05:00 committed by Connor Tsui
parent 84fd95cbed
commit 782b07e1ff
2 changed files with 3 additions and 3 deletions

View File

@ -558,7 +558,7 @@ fn test_downgrade_atomic() {
// modify the protected value.
// `W` is the number of evil writer threads.
const W: usize = if cfg!(target_pointer_width = "64") { 100 } else { 20 };
const W: usize = 20;
let rwlock = Arc::new(RwLock::new(0));
// Spawns many evil writer threads that will try and write to the locked value before the

View File

@ -395,9 +395,9 @@ impl RwLock {
node.next.0 = AtomicPtr::new(state.mask(NODE_MASK).cast());
node.prev = AtomicLink::new(None);
// Set the `QUEUED` bit and maintain the `LOCKED` bit.
// Set the `QUEUED` bit and preserve the `LOCKED` and `DOWNGRADED` bit.
let mut next = ptr::from_ref(&node)
.map_addr(|addr| addr | QUEUED | (state.addr() & LOCKED))
.map_addr(|addr| addr | QUEUED | (state.addr() & (DOWNGRADED | LOCKED)))
as State;
let mut is_queue_locked = false;