|
|
@ -41,18 +41,16 @@ pub struct ProcessManager {
|
|
|
|
wait_queue: Vec<Mutex<Vec<Pid>>>,
|
|
|
|
wait_queue: Vec<Mutex<Vec<Pid>>>,
|
|
|
|
children: Vec<Mutex<Vec<Pid>>>,
|
|
|
|
children: Vec<Mutex<Vec<Pid>>>,
|
|
|
|
event_hub: Mutex<EventHub<Event>>,
|
|
|
|
event_hub: Mutex<EventHub<Event>>,
|
|
|
|
exit_handler: fn(Pid),
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ProcessManager {
|
|
|
|
impl ProcessManager {
|
|
|
|
pub fn new(scheduler: Box<Scheduler>, max_proc_num: usize, exit_handler: fn(Pid)) -> Self {
|
|
|
|
pub fn new(scheduler: Box<Scheduler>, max_proc_num: usize) -> Self {
|
|
|
|
ProcessManager {
|
|
|
|
ProcessManager {
|
|
|
|
procs: new_vec_default(max_proc_num),
|
|
|
|
procs: new_vec_default(max_proc_num),
|
|
|
|
scheduler: Mutex::new(scheduler),
|
|
|
|
scheduler: Mutex::new(scheduler),
|
|
|
|
wait_queue: new_vec_default(max_proc_num),
|
|
|
|
wait_queue: new_vec_default(max_proc_num),
|
|
|
|
children: new_vec_default(max_proc_num),
|
|
|
|
children: new_vec_default(max_proc_num),
|
|
|
|
event_hub: Mutex::new(EventHub::new()),
|
|
|
|
event_hub: Mutex::new(EventHub::new()),
|
|
|
|
exit_handler,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -231,9 +229,7 @@ impl ProcessManager {
|
|
|
|
for waiter in self.wait_queue[pid].lock().iter() {
|
|
|
|
for waiter in self.wait_queue[pid].lock().iter() {
|
|
|
|
self.wakeup(*waiter);
|
|
|
|
self.wakeup(*waiter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
proc.context = None;
|
|
|
|
proc.context = None;
|
|
|
|
(self.exit_handler)(pid);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|