forked from Rativel/BurritOS
Fix thread
This commit is contained in:
committed by
François Autin
parent
ec07158633
commit
75e5c17f28
@@ -51,23 +51,9 @@ impl Thread {
|
||||
let base_stack_addr: [i8; SIMULATORSTACKSIZE] = [0; SIMULATORSTACKSIZE]; // todo AllocBoundedArray
|
||||
self.init_simulator_context(base_stack_addr);
|
||||
self.process.as_mut().unwrap().num_thread += 1;
|
||||
match G_ALIVE.write() {
|
||||
Ok(mut alive) => {
|
||||
let this = Arc::new(self);
|
||||
alive.push(Arc::clone(&this));
|
||||
match G_SCHEDULER.write() {
|
||||
Ok(mut scheduler) => {
|
||||
scheduler.ready_to_run(Arc::clone(&this));
|
||||
},
|
||||
Err(err) => {
|
||||
panic!("RwLock poisonned, {}", err);
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
panic!("RwLock poisonned, {}", err);
|
||||
}
|
||||
}
|
||||
let this = Rc::new(self);
|
||||
self.system.get_g_alive().push(Rc::clone(&this));
|
||||
self.system.g_scheduler().ready_to_run(Rc::clone(&this));
|
||||
Result::Ok(())
|
||||
}
|
||||
|
||||
@@ -93,16 +79,9 @@ impl Thread {
|
||||
}
|
||||
|
||||
/// Wait for another thread to finish its execution
|
||||
pub fn join(&self, id_thread: Arc<Thread>) {
|
||||
match G_ALIVE.write() {
|
||||
Ok(alive) => {
|
||||
while alive.contains(&Arc::clone(&id_thread)) {
|
||||
self.t_yield();
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
panic!("RwLock poisonned, {}", err)
|
||||
}
|
||||
pub fn join(&self, id_thread: Rc<Thread>) {
|
||||
while self.system.get_g_alive().contains(&Rc::clone(&id_thread)) {
|
||||
self.t_yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user