Implement many process syscalls.
This commit is contained in:
parent
e56ea17566
commit
8fbadfc951
20 changed files with 383 additions and 88 deletions
|
@ -5,7 +5,7 @@ use spin::Mutex;
|
|||
use lazy_static::*;
|
||||
|
||||
pub struct TaskManager {
|
||||
ready_queue: VecDeque<Arc<Mutex<TaskControlBlock>>>,
|
||||
ready_queue: VecDeque<Arc<TaskControlBlock>>,
|
||||
}
|
||||
|
||||
/// A simple FIFO scheduler.
|
||||
|
@ -13,10 +13,10 @@ impl TaskManager {
|
|||
pub fn new() -> Self {
|
||||
Self { ready_queue: VecDeque::new(), }
|
||||
}
|
||||
pub fn add(&mut self, task: Arc<Mutex<TaskControlBlock>>) {
|
||||
pub fn add(&mut self, task: Arc<TaskControlBlock>) {
|
||||
self.ready_queue.push_back(task);
|
||||
}
|
||||
pub fn fetch(&mut self) -> Option<Arc<Mutex<TaskControlBlock>>> {
|
||||
pub fn fetch(&mut self) -> Option<Arc<TaskControlBlock>> {
|
||||
self.ready_queue.pop_front()
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ lazy_static! {
|
|||
pub static ref TASK_MANAGER: Mutex<TaskManager> = Mutex::new(TaskManager::new());
|
||||
}
|
||||
|
||||
pub fn add_task(task: Arc<Mutex<TaskControlBlock>>) {
|
||||
pub fn add_task(task: Arc<TaskControlBlock>) {
|
||||
TASK_MANAGER.lock().add(task);
|
||||
}
|
||||
|
||||
pub fn fetch_task() -> Option<Arc<Mutex<TaskControlBlock>>> {
|
||||
pub fn fetch_task() -> Option<Arc<TaskControlBlock>> {
|
||||
TASK_MANAGER.lock().fetch()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue