BurritOS/src/kernel/system.rs

52 lines
1.2 KiB
Rust
Raw Normal View History

//! # System module
//!
//! Module containing structs and methods pertaining to the state of the operating system
use super::{thread_manager::ThreadManager};
2023-04-05 16:43:09 +02:00
use crate::utility;
use crate::utility::objaddr::{ObjAddr, SynchObj};
2023-03-01 11:10:15 +01:00
2023-03-08 15:16:10 +01:00
/// # System
///
/// This structure represents the state of the threads running on the operating system.
/// It contains references to the following:
///
/// - The simulated machine
/// - The current running thread
/// - The list of active threads
/// - The thread to be destroyed next
/// - The scheduler which acts upon these threads
2023-04-05 16:43:09 +02:00
pub struct System<'a> {
thread_manager: ThreadManager,
obj_addrs: ObjAddr<'a>
2023-03-08 15:16:10 +01:00
}
2023-03-01 11:10:15 +01:00
2023-04-05 16:43:09 +02:00
impl<'a> System<'a> {
2023-03-01 15:45:49 +01:00
2023-03-08 15:16:10 +01:00
// GETTERS
2023-03-01 10:11:19 +01:00
2023-03-15 16:28:29 +01:00
pub fn get_thread_manager(&mut self) -> &mut ThreadManager {
&mut self.thread_manager
2023-03-15 11:09:34 +01:00
}
2023-04-05 16:43:09 +02:00
pub fn get_obj_addrs(&mut self) -> &'a mut ObjAddr { &mut self.obj_addrs }
2023-03-22 15:48:29 +01:00
}
2023-03-08 15:16:10 +01:00
2023-04-05 16:43:09 +02:00
impl<'a> Default for System<'a> {
2023-03-22 15:48:29 +01:00
/// System constructor
fn default() -> Self {
2023-04-05 16:43:09 +02:00
Self { thread_manager: ThreadManager::new(), obj_addrs: ObjAddr::init() }
2023-03-08 15:16:10 +01:00
}
}
2023-02-28 14:43:40 +01:00
#[derive(PartialEq, Debug)]
2023-02-28 14:43:40 +01:00
pub enum ObjectType {
SemaphoreType,
LockType,
ConditionType,
FileType,
ThreadType,
InvalidType
}