Add MutexSpin and several syscalls.

This commit is contained in:
Yifan Wu 2021-10-07 12:40:47 -07:00
parent d1e55d85d8
commit 8974a29245
8 changed files with 159 additions and 2 deletions

View file

@ -4,7 +4,7 @@ use crate::mm::{
translated_refmut,
};
use crate::trap::{TrapContext, trap_handler};
use crate::sync::UPSafeCell;
use crate::sync::{UPSafeCell, Mutex};
use core::cell::RefMut;
use super::id::RecycleAllocator;
use super::TaskControlBlock;
@ -32,6 +32,7 @@ pub struct ProcessControlBlockInner {
pub fd_table: Vec<Option<Arc<dyn File + Send + Sync>>>,
pub tasks: Vec<Option<Arc<TaskControlBlock>>>,
pub task_res_allocator: RecycleAllocator,
pub mutex_list: Vec<Option<Arc<dyn Mutex>>>,
}
impl ProcessControlBlockInner {
@ -95,6 +96,7 @@ impl ProcessControlBlock {
],
tasks: Vec::new(),
task_res_allocator: RecycleAllocator::new(),
mutex_list: Vec::new(),
})}
});
// create a main thread, we should allocate ustack and trap_cx here
@ -207,6 +209,7 @@ impl ProcessControlBlock {
fd_table: new_fd_table,
tasks: Vec::new(),
task_res_allocator: RecycleAllocator::new(),
mutex_list: Vec::new(),
})}
});
// add child