Fix exceptions with semaphore

This commit is contained in:
2023-04-12 14:49:08 +02:00
parent 134e2bd2cc
commit 21f3a72a3d
5 changed files with 64 additions and 25 deletions

View File

@@ -7,12 +7,13 @@ use std::rc::Rc;
use super::thread_manager::ThreadManager;
/// Structure of a Semaphore used for synchronisation
#[derive(PartialEq)]
pub struct Semaphore {
/// Counter of simultanous Semaphore
counter:i32,
pub counter:i32,
/// QUeue of Semaphore waiting to be exucated
waiting_queue:List<Rc<RefCell<Thread>>>,
pub waiting_queue:List<Rc<RefCell<Thread>>>,
}
@@ -78,7 +79,8 @@ impl Semaphore {
/// Lock used for synchronisation, can be interpreted has a Semaphore with a
/// counter of 1
/// It's used for critical parts
pub struct Lock{
#[derive(PartialEq)]
pub struct Lock {
/// Thread owning the lock
owner: Option<Rc<RefCell<Thread>>>,