Move system to the right location

This commit is contained in:
Quentin Legot
2023-03-01 17:01:02 +01:00
committed by François Autin
parent 83df053dc6
commit 621b0568b0
5 changed files with 7 additions and 8 deletions

View File

@ -1,4 +1,5 @@
mod process;
pub mod thread;
pub mod scheduler;
pub mod mgerror;
pub mod mgerror;
pub mod system;

View File

@ -2,8 +2,8 @@ use std::sync::Arc;
use crate::utility::list::List;
use crate::kernel::thread::Thread;
use crate::utility::system::{G_CURRENT_THREAD, G_THREAD_TO_BE_DESTROYED};
use super::system::{G_CURRENT_THREAD, G_THREAD_TO_BE_DESTROYED};
pub struct Scheduler {
ready_list: List<Arc<Thread>>

25
src/kernel/system.rs Normal file
View File

@ -0,0 +1,25 @@
use std::{sync::{RwLock, Arc}};
use lazy_static::lazy_static;
use crate::{kernel::{thread::Thread, scheduler::Scheduler}, utility::list::List};
extern crate lazy_static;
lazy_static! {
pub static ref G_CURRENT_THREAD: RwLock<Option<Thread>> = RwLock::new(Option::None);
pub static ref G_THREAD_TO_BE_DESTROYED: RwLock<Option<Thread>> = RwLock::new(Option::None);
pub static ref G_ALIVE: RwLock<List<Arc<Thread>>> = RwLock::new(List::new());
pub static ref G_SCHEDULER: RwLock<Scheduler> = RwLock::new(Scheduler::new());
}
#[derive(PartialEq)]
pub enum ObjectType {
SemaphoreType,
LockType,
ConditionType,
FileType,
ThreadType,
InvalidType
}

View File

@ -1,7 +1,7 @@
use std::sync::Arc;
use super::{process::Process, mgerror::ErrorCode};
use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}, utility::system::{ObjectType, G_ALIVE, G_SCHEDULER}, kernel::scheduler};
use super::{process::Process, mgerror::ErrorCode, system::{ObjectType, G_ALIVE, G_SCHEDULER}};
use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}};
const SIMULATORSTACKSIZE: usize = 32 * 1024;