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:
@@ -1,11 +1,12 @@
|
||||
use alloc::{sync::Arc, vec::Vec};
|
||||
use spin::{Mutex, MutexGuard, RwLock};
|
||||
use spin::{Mutex, MutexGuard};
|
||||
use spinning_top::RwSpinlock;
|
||||
|
||||
use crate::context::{self, Context};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WaitCondition {
|
||||
contexts: Mutex<Vec<Arc<RwLock<Context>>>>,
|
||||
contexts: Mutex<Vec<Arc<RwSpinlock<Context>>>>,
|
||||
}
|
||||
|
||||
impl WaitCondition {
|
||||
|
||||
Reference in New Issue
Block a user