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:
bjorn3
2024-02-25 17:07:41 +01:00
parent 449abb8925
commit 782ec87f27
9 changed files with 68 additions and 56 deletions
+2 -1
View File
@@ -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.