Still a lot of bugs :(
This commit is contained in:
parent
704eae3bb0
commit
26f44233f6
27 changed files with 308 additions and 95 deletions
|
@ -1,4 +1,4 @@
|
|||
use super::UPSafeCell;
|
||||
use super::UPIntrFreeCell;
|
||||
use crate::task::TaskControlBlock;
|
||||
use crate::task::{add_task, current_task};
|
||||
use crate::task::{block_current_and_run_next, suspend_current_and_run_next};
|
||||
|
@ -10,13 +10,13 @@ pub trait Mutex: Sync + Send {
|
|||
}
|
||||
|
||||
pub struct MutexSpin {
|
||||
locked: UPSafeCell<bool>,
|
||||
locked: UPIntrFreeCell<bool>,
|
||||
}
|
||||
|
||||
impl MutexSpin {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
locked: unsafe { UPSafeCell::new(false) },
|
||||
locked: unsafe { UPIntrFreeCell::new(false) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ impl Mutex for MutexSpin {
|
|||
}
|
||||
|
||||
pub struct MutexBlocking {
|
||||
inner: UPSafeCell<MutexBlockingInner>,
|
||||
inner: UPIntrFreeCell<MutexBlockingInner>,
|
||||
}
|
||||
|
||||
pub struct MutexBlockingInner {
|
||||
|
@ -55,7 +55,7 @@ impl MutexBlocking {
|
|||
pub fn new() -> Self {
|
||||
Self {
|
||||
inner: unsafe {
|
||||
UPSafeCell::new(MutexBlockingInner {
|
||||
UPIntrFreeCell::new(MutexBlockingInner {
|
||||
locked: false,
|
||||
wait_queue: VecDeque::new(),
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue