remove Process struct

master
WangRunji 6 years ago
parent 205f90a264
commit da399dca96

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

@ -11,7 +11,7 @@ pub mod context;
pub fn init() {
// NOTE: max_time_slice <= 5 to ensure 'priority' test pass
let scheduler = Box::new(scheduler::RRScheduler::new(5));
let manager = Arc::new(ProcessManager::new(scheduler, MAX_PROCESS_NUM, Process::proc_exit));
let manager = Arc::new(ProcessManager::new(scheduler, MAX_PROCESS_NUM));
extern fn idle(_arg: usize) -> ! {
loop { cpu::halt(); }
@ -30,18 +30,6 @@ pub fn init() {
static PROCESSORS: [Processor; MAX_CPU_NUM] = [Processor::new(), Processor::new(), Processor::new(), Processor::new(), Processor::new(), Processor::new(), Processor::new(), Processor::new()];
#[derive(Default)]
pub struct Process {
parent: AtomicUsize,
children: Mutex<Vec<usize>>,
}
impl Process {
pub fn proc_exit(pid: usize) {
info!("proc_exit");
}
}
/// Get current thread struct
pub fn process() -> &'static mut ContextImpl {
use core::mem::transmute;

Loading…
Cancel
Save