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};
type Error = String;
/// The halt system call. Stops Burritos.
pub const SC_SHUTDOWN: u8 = 0;
/// The exit system call

View File

@ -142,6 +142,7 @@ impl Lock {
}
/// Structure of a condition used for synchronisation
#[allow(unused)] // -> No enough time to implement it
pub struct Condition{
/// The queue of threads waiting for execution
@ -155,6 +156,7 @@ impl Condition {
///
/// ### Parameters
/// - *thread_manager* Thread manager which managing threads
#[allow(unused)]
pub fn new() -> Condition {
Condition{ waiting_queue: List::default()}
}
@ -165,6 +167,7 @@ impl Condition {
/// ### Parameters
/// - **current_thread** the current thread
/// - **machine** the machine where threads are executed
#[allow(unused)]
pub fn wait(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) {
let old_status = machine.interrupt.set_status(InterruptOff);
match thread_manager.get_g_current_thread() {
@ -186,6 +189,7 @@ impl Condition {
/// ### Parameters
/// - **machine** the machine where the code is executed
/// - **scheduler** the scheduler which determine which thread to execute
#[allow(unused)]
pub fn signal(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) {
let old_status = machine.interrupt.set_status(InterruptOff);
@ -204,6 +208,7 @@ impl Condition {
/// ### Parameters
/// - **machine** the machine where the code is executed
/// - **scheduler** the scheduler which determine which thread to execute
#[allow(unused)]
pub fn broadcast(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) {
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 super::{process::Process, system::ObjectType};
use super::process::Process;
use crate::{simulator::machine::{NUM_INT_REGS, NUM_FP_REGS, STACK_REG}};
const STACK_FENCEPOST: u32 = 0xdeadbeef;
@ -27,7 +27,6 @@ pub struct Thread {
pub process: Option<Rc<RefCell<Process>>>,
pub thread_context: ThreadContext,
pub stack_pointer: i32,
object_type: ObjectType
}
impl Thread {
@ -44,7 +43,6 @@ impl Thread {
pc: 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)]
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";
/// This macro allows for getting a Thread for which we've ensured proper initial state
@ -110,7 +95,6 @@ mod test {
pc: 0
};
x.stack_pointer = 0;
x.object_type = ObjectType::ThreadType;
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 super::{thread::Thread, process::Process, synch::Semaphore};
use super::{thread::Thread, process::Process};
pub const SIMULATORSTACKSIZE: usize = 32 * 1024;
@ -273,7 +273,7 @@ impl ThreadManager {
mod test {
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]
fn test_thread_context() {
@ -334,7 +334,7 @@ mod test {
// Init
let mut tm = ThreadManager::new();
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 thread1 = Rc::new(RefCell::new(Thread::new("test_semaphore_1")));
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
running on RISC-V emulator.", long_about = None)]
/// Launch argument parser
struct Args {
/// Enable debug mode
#[arg(short, long)]

View File

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

View File

@ -35,14 +35,14 @@ impl ObjAddr {
/// Adds the **obj** Semaphore to self
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.last_id
}
/// Adds the **obj** Lock to self
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.last_id
}