Fix UB in the locking code of context switching
The spin crate considers it UB to call force_write_unlock while there is a threads trying to obtain a read lock on the same rwlock. This also switches to the spinning_lot crate for the context rwlock as it has support for a write guard keeping a reference to the rwlock using an Arc instead of a reference.
This commit is contained in:
@@ -6,6 +6,7 @@ use alloc::{collections::VecDeque, sync::Arc};
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
use rmm::Arch;
|
||||
use spin::RwLock;
|
||||
use spinning_top::RwSpinlock;
|
||||
|
||||
use crate::{
|
||||
context::{self, memory::AddrSpace, Context},
|
||||
@@ -26,7 +27,7 @@ type FutexList = VecDeque<FutexEntry>;
|
||||
|
||||
pub struct FutexEntry {
|
||||
target_physaddr: PhysicalAddress,
|
||||
context_lock: Arc<RwLock<Context>>,
|
||||
context_lock: Arc<RwSpinlock<Context>>,
|
||||
}
|
||||
|
||||
// TODO: Process-private futexes? In that case, put the futex table in each AddrSpace.
|
||||
|
||||
Reference in New Issue
Block a user