Merge remote-tracking branch 'origin/thread_scheduler' into thread_scheduler
This commit is contained in:
commit
5b8abd2a07
@ -6,17 +6,26 @@ use super::{scheduler::Scheduler, thread::Thread, system::System, mgerror::Error
|
|||||||
|
|
||||||
pub const SIMULATORSTACKSIZE: usize = 32 * 1024;
|
pub const SIMULATORSTACKSIZE: usize = 32 * 1024;
|
||||||
|
|
||||||
|
/// # Thread manager
|
||||||
|
///
|
||||||
|
/// An instance of this struct is responsible for managing threads on behalf of the system
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub struct ThreadManager {
|
pub struct ThreadManager {
|
||||||
|
/// Current running thread
|
||||||
pub g_current_thread: Option<Rc<RefCell<Thread>>>,
|
pub g_current_thread: Option<Rc<RefCell<Thread>>>,
|
||||||
|
/// The thread to be destroyed next
|
||||||
pub g_thread_to_be_destroyed: Option<Rc<RefCell<Thread>>>,
|
pub g_thread_to_be_destroyed: Option<Rc<RefCell<Thread>>>,
|
||||||
|
/// The list of alive threads
|
||||||
pub g_alive: List<Rc<RefCell<Thread>>>,
|
pub g_alive: List<Rc<RefCell<Thread>>>,
|
||||||
|
/// The thread scheduler
|
||||||
pub g_scheduler: Scheduler,
|
pub g_scheduler: Scheduler,
|
||||||
|
/// The system owning the thread manager
|
||||||
pub system: Option<Rc<RefCell<System>>>
|
pub system: Option<Rc<RefCell<System>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ThreadManager {
|
impl ThreadManager {
|
||||||
|
|
||||||
|
/// Thread manager constructor
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
g_current_thread: Option::None,
|
g_current_thread: Option::None,
|
||||||
|
@ -1,49 +1,41 @@
|
|||||||
|
///! FILE.TXT FORMAT Representing machine memory memory
|
||||||
|
/// - PC
|
||||||
|
/// - SP
|
||||||
|
/// - Section_1
|
||||||
|
/// - Section_2
|
||||||
|
/// - ...
|
||||||
|
/// - Section_n
|
||||||
|
///
|
||||||
|
/// Each section is divided in 3 parts, on two lines of text
|
||||||
|
/// addr SPACE len
|
||||||
|
/// content
|
||||||
|
|
||||||
use std::{fs, io::{BufRead, BufReader, Lines, Error}};
|
use std::{fs, io::{BufRead, BufReader, Lines, Error}};
|
||||||
use crate::Machine;
|
use crate::Machine;
|
||||||
|
|
||||||
const MEM_SIZE : usize = 4096;
|
|
||||||
|
|
||||||
/* FORMAT FICHIER.TXT Représentant la mémoire apres éxecution d'un prog
|
|
||||||
* PC
|
|
||||||
* SP
|
|
||||||
* Section_1
|
|
||||||
* Section_2
|
|
||||||
* ...
|
|
||||||
* ...
|
|
||||||
* Section_n
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Chaque section se divise en 3 parties, sur 2 lignes de texte
|
|
||||||
* addr ESPACE len
|
|
||||||
* content
|
|
||||||
*/
|
|
||||||
|
|
||||||
//content est une suite hexadécimale
|
|
||||||
|
|
||||||
/// File section
|
/// File section
|
||||||
pub struct SectionFormat{
|
pub struct SectionFormat{
|
||||||
|
/// Memory address of the section
|
||||||
addr: String,
|
addr: String,
|
||||||
|
/// The size of data in bytes
|
||||||
len: String,
|
len: String,
|
||||||
|
/// The data itself in Hexadecimal format
|
||||||
content: String,
|
content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Memory section
|
/// # Memory section
|
||||||
///
|
///
|
||||||
/// Representation of a section of memory from BurritOS or NachOS
|
/// Representation of a section of memory from BurritOS or NachOS
|
||||||
///
|
|
||||||
/// - addr: Memory address of the section
|
|
||||||
/// - len: The size of data in bytes
|
|
||||||
/// - content: the data itself
|
|
||||||
pub struct Section{
|
pub struct Section{
|
||||||
addr: usize, // adresse dans la mémoire
|
/// Memory address of the section
|
||||||
len: usize, // nombre d'octets de la donnée à addr
|
addr: usize,
|
||||||
content: Vec<u8>, // la donnée en question
|
/// The size of data in bytes
|
||||||
|
len: usize,
|
||||||
|
/// The data itself in Hexadecimal format
|
||||||
|
content: Vec<u8>
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
impl Section {
|
||||||
* Voir si instanciation d'une structure deplace les valeurs "locales" à la méthode from, je sais plus ....
|
|
||||||
*/
|
|
||||||
impl Section{
|
|
||||||
|
|
||||||
/// Creates a memory section from a SectionFormat
|
/// Creates a memory section from a SectionFormat
|
||||||
fn from(section: &SectionFormat) -> Section {
|
fn from(section: &SectionFormat) -> Section {
|
||||||
@ -61,12 +53,17 @@ impl Section{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Representation de l'etat de la mémoire (apres execution.... a confirmer), sous forme de sections
|
/// # Representation of the state of machine memory
|
||||||
*/
|
///
|
||||||
pub struct MemChecker{
|
/// Could represent memory at any point in time, before, during, or after execution.
|
||||||
|
/// The memory is split into sections.
|
||||||
|
pub struct MemChecker {
|
||||||
|
/// Value of the program counter
|
||||||
pc: usize,
|
pc: usize,
|
||||||
|
/// Value of the stack pointer
|
||||||
sp: usize,
|
sp: usize,
|
||||||
|
/// Sections
|
||||||
sections: Vec<Section>,
|
sections: Vec<Section>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,20 +178,13 @@ impl MemChecker{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/// For debug
|
||||||
* FOR DEBUG
|
|
||||||
*/
|
|
||||||
fn compare_print_m_c_machine(m_c: &MemChecker, machine: &mut Machine){
|
fn compare_print_m_c_machine(m_c: &MemChecker, machine: &mut Machine){
|
||||||
|
|
||||||
MemChecker::print_mem_checker(m_c);
|
MemChecker::print_mem_checker(m_c);
|
||||||
|
|
||||||
for section in m_c.sections.iter() {
|
for section in m_c.sections.iter() {
|
||||||
|
|
||||||
print!("\n\n");
|
print!("\n\n");
|
||||||
|
|
||||||
println!("Content addr : {}", section.addr);
|
println!("Content addr : {}", section.addr);
|
||||||
println!("Content len (number of bytes) : {}", section.len);
|
println!("Content len (number of bytes) : {}", section.len);
|
||||||
|
|
||||||
for i in 0..section.len {
|
for i in 0..section.len {
|
||||||
println!("mem[{}] = {}", section.addr + i, machine.main_memory[section.addr + i]);
|
println!("mem[{}] = {}", section.addr + i, machine.main_memory[section.addr + i]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user