forked from Rativel/BurritOS
remove machine from system
This commit is contained in:
@@ -2,22 +2,8 @@
|
||||
//!
|
||||
//! Module containing structs and methods pertaining to the state of the operating system
|
||||
|
||||
use crate::simulator::machine::Machine;
|
||||
|
||||
use super::{thread_manager::ThreadManager};
|
||||
|
||||
/// This macro properly initializes the system
|
||||
#[macro_export]
|
||||
macro_rules! init_system {
|
||||
() => {{
|
||||
let m = Machine::init_machine();
|
||||
init_system!(m)
|
||||
}};
|
||||
($a:expr) => {{
|
||||
$crate::System::new($a)
|
||||
}};
|
||||
}
|
||||
|
||||
/// # System
|
||||
///
|
||||
/// This structure represents the state of the threads running on the operating system.
|
||||
@@ -30,40 +16,24 @@ macro_rules! init_system {
|
||||
/// - The scheduler which acts upon these threads
|
||||
#[derive(PartialEq)]
|
||||
pub struct System {
|
||||
machine: Machine,
|
||||
thread_manager: ThreadManager
|
||||
}
|
||||
|
||||
impl System {
|
||||
|
||||
/// System constructor
|
||||
pub fn new(machine: Machine) -> System {
|
||||
Self {
|
||||
machine,
|
||||
thread_manager: ThreadManager::new()
|
||||
}
|
||||
}
|
||||
|
||||
// GETTERS
|
||||
|
||||
/// Returns the Machine
|
||||
///
|
||||
/// Useful to access RAM, devices, ...
|
||||
pub fn get_machine(&mut self) -> &mut Machine {
|
||||
&mut self.machine
|
||||
}
|
||||
|
||||
pub fn get_thread_manager(&mut self) -> &mut ThreadManager {
|
||||
&mut self.thread_manager
|
||||
}
|
||||
|
||||
// Setters
|
||||
}
|
||||
|
||||
/// Assign a machine to the system
|
||||
pub fn set_machine(&mut self, machine: Machine) {
|
||||
self.machine = machine
|
||||
impl Default for System {
|
||||
/// System constructor
|
||||
fn default() -> Self {
|
||||
Self { thread_manager: ThreadManager::new() }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
@@ -75,15 +45,3 @@ pub enum ObjectType {
|
||||
ThreadType,
|
||||
InvalidType
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::Machine;
|
||||
|
||||
#[test]
|
||||
fn test_init_system() {
|
||||
init_system!();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user