Still a lot of bugs :(

This commit is contained in:
Yifan Wu 2022-03-04 09:02:32 -08:00
parent 704eae3bb0
commit 26f44233f6
27 changed files with 308 additions and 95 deletions

View file

@ -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(),
})