1
0
forked from Rativel/BurritOS

Implemente finish (not finished yet), fix ucontext for windows

This commit is contained in:
Quentin Legot
2023-03-08 13:21:08 +01:00
committed by François Autin
parent 3457f67a7c
commit dc49951bab
5 changed files with 55 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
use std::{sync::Arc};
use super::{process::Process, mgerror::ErrorCode, system::{ObjectType, G_ALIVE, G_SCHEDULER}, ucontext::UContextT};
use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}};
use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}, kernel::system::{G_MACHINE, G_THREAD_TO_BE_DESTROYED}};
const SIMULATORSTACKSIZE: usize = 32 * 1024;
const STACK_FENCEPOST: u32 = 0xdeadbeef;
@@ -116,7 +116,34 @@ impl Thread {
}
/// Finish the execution of the thread and prepare its deallocation
pub fn finish(&self) {
pub fn finish(mut self) {
match G_MACHINE.write() {
Ok(mut machine) => {
let old_status = machine.interrupt.set_status(crate::simulator::interrupt::InterruptStatus::InterruptOff);
match G_ALIVE.write() {
Ok(alive) => {
// todo alive.remove(T) à implémenter dans List
},
Err(err) => {
panic!("RwLock is poisoned: {}", err);
}
}
match G_THREAD_TO_BE_DESTROYED.write() {
Ok(mut thread_to_be_destroyed) => {
thread_to_be_destroyed.replace(self);
},
Err(err) => {
panic!("RwLock is poisoned: {}", err);
}
}
// self.sleep();
machine.interrupt.set_status(old_status);
},
Err(err) => {
panic!("RwLock is poisoned: {}", err);
}
}
todo!();
}