lint: remove some warning

This commit is contained in:
Quentin Legot 2023-04-12 15:32:46 +02:00
parent 752b70e448
commit 35736821c0
8 changed files with 14 additions and 35 deletions

View File

@ -4,8 +4,6 @@ use crate::{simulator::{machine::{ExceptionType, Machine}, error::{MachineOk, Ma
use super::{system::System, thread::Thread}; use super::{system::System, thread::Thread};
type Error = String;
/// The halt system call. Stops Burritos. /// The halt system call. Stops Burritos.
pub const SC_SHUTDOWN: u8 = 0; pub const SC_SHUTDOWN: u8 = 0;
/// The exit system call /// The exit system call

View File

@ -142,6 +142,7 @@ impl Lock {
} }
/// Structure of a condition used for synchronisation /// Structure of a condition used for synchronisation
#[allow(unused)] // -> No enough time to implement it
pub struct Condition{ pub struct Condition{
/// The queue of threads waiting for execution /// The queue of threads waiting for execution
@ -155,6 +156,7 @@ impl Condition {
/// ///
/// ### Parameters /// ### Parameters
/// - *thread_manager* Thread manager which managing threads /// - *thread_manager* Thread manager which managing threads
#[allow(unused)]
pub fn new() -> Condition { pub fn new() -> Condition {
Condition{ waiting_queue: List::default()} Condition{ waiting_queue: List::default()}
} }
@ -165,6 +167,7 @@ impl Condition {
/// ### Parameters /// ### Parameters
/// - **current_thread** the current thread /// - **current_thread** the current thread
/// - **machine** the machine where threads are executed /// - **machine** the machine where threads are executed
#[allow(unused)]
pub fn wait(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) { pub fn wait(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) {
let old_status = machine.interrupt.set_status(InterruptOff); let old_status = machine.interrupt.set_status(InterruptOff);
match thread_manager.get_g_current_thread() { match thread_manager.get_g_current_thread() {
@ -186,6 +189,7 @@ impl Condition {
/// ### Parameters /// ### Parameters
/// - **machine** the machine where the code is executed /// - **machine** the machine where the code is executed
/// - **scheduler** the scheduler which determine which thread to execute /// - **scheduler** the scheduler which determine which thread to execute
#[allow(unused)]
pub fn signal(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) { pub fn signal(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) {
let old_status = machine.interrupt.set_status(InterruptOff); let old_status = machine.interrupt.set_status(InterruptOff);
@ -204,6 +208,7 @@ impl Condition {
/// ### Parameters /// ### Parameters
/// - **machine** the machine where the code is executed /// - **machine** the machine where the code is executed
/// - **scheduler** the scheduler which determine which thread to execute /// - **scheduler** the scheduler which determine which thread to execute
#[allow(unused)]
pub fn broadcast(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) { pub fn broadcast(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) {
let old_status = machine.interrupt.set_status(InterruptOff); let old_status = machine.interrupt.set_status(InterruptOff);

View File

@ -35,12 +35,3 @@ impl Default for System {
} }
} }
#[derive(PartialEq, Debug)]
pub enum ObjectType {
SemaphoreType,
LockType,
ConditionType,
FileType,
ThreadType,
InvalidType
}

View File

@ -1,6 +1,6 @@
use std::{rc::Rc, cell::RefCell}; use std::{rc::Rc, cell::RefCell};
use super::{process::Process, system::ObjectType}; use super::process::Process;
use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}}; use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}};
const STACK_FENCEPOST: u32 = 0xdeadbeef; const STACK_FENCEPOST: u32 = 0xdeadbeef;
@ -27,7 +27,6 @@ pub struct Thread {
pub process: Option<Rc<RefCell<Process>>>, pub process: Option<Rc<RefCell<Process>>>,
pub thread_context: ThreadContext, pub thread_context: ThreadContext,
pub stack_pointer: i32, pub stack_pointer: i32,
object_type: ObjectType
} }
impl Thread { impl Thread {
@ -44,7 +43,6 @@ impl Thread {
pc: 0 pc: 0
}, },
stack_pointer: 0, stack_pointer: 0,
object_type: ObjectType::ThreadType,
} }
} }
@ -76,23 +74,10 @@ impl Thread {
} }
impl Drop for Thread {
fn drop(&mut self) {
self.object_type = ObjectType::InvalidType;
// todo!();
}
}
fn start_thread_execution() {
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::{Thread, ThreadContext, NUM_INT_REGS, NUM_FP_REGS, ObjectType}; use super::{Thread, ThreadContext, NUM_INT_REGS, NUM_FP_REGS};
const DEFAULT_THREAD_NAME: &str = "test_thread"; const DEFAULT_THREAD_NAME: &str = "test_thread";
/// This macro allows for getting a Thread for which we've ensured proper initial state /// This macro allows for getting a Thread for which we've ensured proper initial state
@ -110,7 +95,6 @@ mod test {
pc: 0 pc: 0
}; };
x.stack_pointer = 0; x.stack_pointer = 0;
x.object_type = ObjectType::ThreadType;
x } x }
}; };
} }

View File

@ -2,7 +2,7 @@ use std::{rc::Rc, cell::{RefCell, Ref}};
use crate::{utility::{list::List, objaddr::ObjAddr}, simulator::{machine::{NUM_INT_REGS, NUM_FP_REGS, Machine}, interrupt::InterruptStatus, error::{MachineOk, MachineError}}}; use crate::{utility::{list::List, objaddr::ObjAddr}, simulator::{machine::{NUM_INT_REGS, NUM_FP_REGS, Machine}, interrupt::InterruptStatus, error::{MachineOk, MachineError}}};
use super::{thread::Thread, process::Process, synch::Semaphore}; use super::{thread::Thread, process::Process};
pub const SIMULATORSTACKSIZE: usize = 32 * 1024; pub const SIMULATORSTACKSIZE: usize = 32 * 1024;
@ -273,7 +273,7 @@ impl ThreadManager {
mod test { mod test {
use std::{rc::Rc, cell::RefCell}; use std::{rc::Rc, cell::RefCell};
use crate::{simulator::{machine::Machine, loader}, kernel::{system::System, thread::Thread, process::Process, thread_manager::{ThreadManager, self}, synch::Semaphore}}; use crate::{simulator::{machine::Machine, loader}, kernel::{system::System, thread::Thread, process::Process, thread_manager::ThreadManager, synch::Semaphore}};
#[test] #[test]
fn test_thread_context() { fn test_thread_context() {
@ -334,7 +334,7 @@ mod test {
// Init // Init
let mut tm = ThreadManager::new(); let mut tm = ThreadManager::new();
let mut machine = Machine::new(true); let mut machine = Machine::new(true);
let mut semaphore = Semaphore::new(2); let semaphore = Semaphore::new(2);
let sema_id = tm.get_obj_addrs().add_semaphore(semaphore); let sema_id = tm.get_obj_addrs().add_semaphore(semaphore);
let thread1 = Rc::new(RefCell::new(Thread::new("test_semaphore_1"))); let thread1 = Rc::new(RefCell::new(Thread::new("test_semaphore_1")));
let thread2 = Rc::new(RefCell::new(Thread::new("test_semaphore_2"))); let thread2 = Rc::new(RefCell::new(Thread::new("test_semaphore_2")));

View File

@ -26,6 +26,7 @@ use clap::Parser;
Burritos is an educational operating system written in Rust Burritos is an educational operating system written in Rust
running on RISC-V emulator.", long_about = None)] running on RISC-V emulator.", long_about = None)]
/// Launch argument parser
struct Args { struct Args {
/// Enable debug mode /// Enable debug mode
#[arg(short, long)] #[arg(short, long)]

View File

@ -120,7 +120,7 @@ impl<T: PartialEq> List<T> {
let mut current: *mut Node<T> = self.head; let mut current: *mut Node<T> = self.head;
let mut previous: *mut Node<T> = ptr::null_mut(); let mut previous: *mut Node<T> = ptr::null_mut();
while !current.is_null() { while !current.is_null() {
if (&*current).elem == item { if (*current).elem == item {
if !previous.is_null() { if !previous.is_null() {
(*previous).next = (*current).next; (*previous).next = (*current).next;
} else { } else {

View File

@ -35,14 +35,14 @@ impl ObjAddr {
/// Adds the **obj** Semaphore to self /// Adds the **obj** Semaphore to self
pub fn add_semaphore(&mut self, obj: Semaphore) -> i32 { pub fn add_semaphore(&mut self, obj: Semaphore) -> i32 {
self.last_id = self.last_id + 1; self.last_id += 1;
self.semaphores.insert(self.last_id, obj); self.semaphores.insert(self.last_id, obj);
self.last_id self.last_id
} }
/// Adds the **obj** Lock to self /// Adds the **obj** Lock to self
pub fn add_lock(&mut self, obj: Lock) -> i32 { pub fn add_lock(&mut self, obj: Lock) -> i32 {
self.last_id = self.last_id + 1; self.last_id += 1;
self.locks.insert(self.last_id, obj); self.locks.insert(self.last_id, obj);
self.last_id self.last_id
} }