Lint: remove some warnings
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::simulator::{machine::{ExceptionType, Machine}, error::{MachineOk, MachineError}};
|
||||
|
||||
use super::system::System;
|
||||
@ -174,9 +172,9 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
|
||||
SC_V => todo!(),
|
||||
SC_SEM_CREATE => {
|
||||
let addr_name = machine.read_int_register(10);
|
||||
let initial_count = machine.read_int_register((11));
|
||||
let initial_count = machine.read_int_register(11);
|
||||
let size = get_length_param(addr_name as usize, machine);
|
||||
let name = get_string_param(addr_name, size, machine);
|
||||
let _name = get_string_param(addr_name, size, machine);
|
||||
|
||||
if initial_count <0{
|
||||
|
||||
@ -240,14 +238,13 @@ fn get_string_param(addr: i64, maxlen: usize, machine: &Machine) -> Vec<char>{
|
||||
mod test {
|
||||
use crate::kernel::exception::{SC_SHUTDOWN, SC_WRITE};
|
||||
use crate::kernel::system::System;
|
||||
use crate::simulator::instruction::Instruction;
|
||||
use crate::simulator::machine::Machine;
|
||||
|
||||
#[test]
|
||||
fn test_sc_shutdown() {
|
||||
let mut machine = Machine::new(true);
|
||||
machine.write_int_register(17, SC_SHUTDOWN as i64); // Set type to shutdown
|
||||
let ecall = Instruction::new(0b000000000000_00000_000_00000_1110011);
|
||||
// let ecall = Instruction::new(0b000000000000_00000_000_00000_1110011);
|
||||
|
||||
machine.write_memory(4, 0, 0b000000000000_00000_000_00000_1110011); // ecall
|
||||
machine.write_memory(4, 4, 0b000000001010_00000_000_00001_0010011); // r1 <- 10
|
||||
@ -263,7 +260,7 @@ mod test {
|
||||
fn test_sc_print() {
|
||||
let mut machine = Machine::new(true);
|
||||
|
||||
let address = machine.read_int_register(10);
|
||||
let _address = machine.read_int_register(10);
|
||||
// Write string 'HELLO' in memory
|
||||
machine.write_memory(1, 4000, 72);
|
||||
machine.write_memory(1, 4001, 69);
|
||||
|
@ -3,8 +3,7 @@
|
||||
//! Module containing structs and methods pertaining to the state of the operating system
|
||||
|
||||
use super::{thread_manager::ThreadManager};
|
||||
use crate::utility;
|
||||
use crate::utility::objaddr::{ObjAddr, SynchObj};
|
||||
use crate::utility::objaddr::ObjAddr;
|
||||
|
||||
/// # System
|
||||
///
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::{process::Process, system::ObjectType, thread_manager::SIMULATORSTACKSIZE};
|
||||
use super::{process::Process, system::ObjectType};
|
||||
use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}};
|
||||
|
||||
const STACK_FENCEPOST: u32 = 0xdeadbeef;
|
||||
@ -23,7 +23,6 @@ pub struct ThreadContext {
|
||||
pub struct Thread {
|
||||
name: String,
|
||||
pub process: Option<Process>,
|
||||
// simulation_context: UContextT,
|
||||
pub thread_context: ThreadContext,
|
||||
pub stack_pointer: i32,
|
||||
object_type: ObjectType
|
||||
@ -52,21 +51,6 @@ impl Thread {
|
||||
self.thread_context.int_registers[10] = arg;
|
||||
self.thread_context.int_registers[STACK_REG] = initial_sp as i64;
|
||||
}
|
||||
|
||||
pub fn init_simulator_context(&self, base_stack_addr: [i8; SIMULATORSTACKSIZE]) {
|
||||
// let res = self.simulation_context.get_context();
|
||||
// if res != 0 {
|
||||
// panic!("getcontext returns non-zero value {}", res);
|
||||
// }
|
||||
// self.simulation_context.buf.uc_stack.ss_sp = base_stack_addr;
|
||||
// self.simulation_context.buf.uc_stack.ss_size = base_stack_addr.len();
|
||||
// self.simulation_context.buf.uc_stack.ss_flags = 0;
|
||||
// self.simulation_context.buf.uc_link = UContextT::new().buf;
|
||||
// self.simulation_context.make_context(start_thread_execution, 0);
|
||||
|
||||
// self.simulation_context.stackBottom = base_stack_addr.to_vec();
|
||||
// self.simulation_context.stackBottom[0] = STACK_FENCEPOST;
|
||||
}
|
||||
|
||||
/// Check if a thread has overflowed its stack
|
||||
///
|
||||
@ -78,14 +62,6 @@ impl Thread {
|
||||
// }
|
||||
}
|
||||
|
||||
pub fn save_simulator_state(&self) {
|
||||
// todo!(); // simulator state will maybe be removed so panic call is remove. See ucontext.rs
|
||||
}
|
||||
|
||||
pub fn restore_simulator_state(&self) {
|
||||
// todo!(); // simulator state will maybe be removed so panic call is remove. See ucontext.rs
|
||||
}
|
||||
|
||||
pub fn get_name(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use std::{rc::Rc, cell::{RefCell, Ref}};
|
||||
|
||||
use crate::{utility::list::List, simulator::{machine::{NUM_INT_REGS, NUM_FP_REGS, Machine}, interrupt::InterruptStatus}};
|
||||
|
||||
use super::{thread::Thread, mgerror::ErrorCode, process::Process};
|
||||
use super::{thread::Thread, process::Process};
|
||||
|
||||
pub const SIMULATORSTACKSIZE: usize = 32 * 1024;
|
||||
|
||||
@ -92,8 +92,6 @@ impl ThreadManager {
|
||||
thread_m.process = Option::Some(owner);
|
||||
let ptr = sp_loc; // todo addrspace
|
||||
thread_m.init_thread_context(func_pc, ptr, argument);
|
||||
let base_stack_addr: [i8; SIMULATORSTACKSIZE] = [0; SIMULATORSTACKSIZE]; // todo AllocBoundedArray
|
||||
thread_m.init_simulator_context(base_stack_addr);
|
||||
thread_m.process.as_mut().unwrap().num_thread += 1;
|
||||
self.get_g_alive().push(Rc::clone(&thread));
|
||||
self.ready_to_run(Rc::clone(&thread));
|
||||
@ -202,7 +200,7 @@ impl ThreadManager {
|
||||
mod test {
|
||||
use std::{rc::Rc, cell::RefCell};
|
||||
|
||||
use crate::{simulator::{machine::Machine, loader}, kernel::{system::System, thread::{Thread, self}, process::Process}};
|
||||
use crate::{simulator::{machine::Machine, loader}, kernel::{system::System, thread::Thread, process::Process}};
|
||||
|
||||
#[test]
|
||||
fn test_thread_context() {
|
||||
|
Reference in New Issue
Block a user