forked from Rativel/BurritOS
Added partialeq trait where relevant
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::{sync::Arc};
|
||||
use std::{sync::Arc, rc::Rc};
|
||||
|
||||
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}, kernel::system::{G_MACHINE, G_THREAD_TO_BE_DESTROYED}};
|
||||
use super::{process::Process, mgerror::ErrorCode, system::{ObjectType, System}, ucontext::UContextT};
|
||||
use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}};
|
||||
|
||||
const SIMULATORSTACKSIZE: usize = 32 * 1024;
|
||||
const STACK_FENCEPOST: u32 = 0xdeadbeef;
|
||||
@@ -20,12 +20,14 @@ pub struct Thread {
|
||||
// simulation_context: UContextT,
|
||||
thread_context: ThreadContext,
|
||||
stack_pointer: i32,
|
||||
object_type: ObjectType
|
||||
object_type: ObjectType,
|
||||
system: Rc<System>
|
||||
}
|
||||
|
||||
impl Thread {
|
||||
|
||||
pub fn new(name: String) -> Self {
|
||||
/// Thread constructor
|
||||
pub fn new(name: String, system: Rc<System>) -> Self {
|
||||
Self {
|
||||
name,
|
||||
process: None,
|
||||
@@ -36,7 +38,8 @@ impl Thread {
|
||||
pc: 0
|
||||
},
|
||||
stack_pointer: 0,
|
||||
object_type: ObjectType::ThreadType
|
||||
object_type: ObjectType::ThreadType,
|
||||
system
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,34 +119,7 @@ impl Thread {
|
||||
}
|
||||
|
||||
/// Finish the execution of the thread and prepare its deallocation
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn finish(&self) {
|
||||
todo!();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user