Added trait SynchObj to relevant structs

This commit is contained in:
François Autin 2023-04-05 16:12:15 +02:00
parent 586c077002
commit 91f5c6054c
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C
2 changed files with 8 additions and 1 deletions

View File

@ -1,4 +1,5 @@
use crate::utility::list::List; use crate::utility::list::List;
use crate::utility::objaddr::*;
use crate::kernel::thread::Thread; use crate::kernel::thread::Thread;
use crate::simulator::interrupt::InterruptStatus::InterruptOff; use crate::simulator::interrupt::InterruptStatus::InterruptOff;
use crate::simulator::machine::Machine; use crate::simulator::machine::Machine;
@ -16,6 +17,8 @@ pub struct Semaphore {
} }
impl SynchObj for Semaphore {}
impl Semaphore { impl Semaphore {
/// Initializes a semaphore, so that it can be used for synchronization. /// Initializes a semaphore, so that it can be used for synchronization.
@ -89,6 +92,8 @@ pub struct Lock{
} }
impl SynchObj for Lock {}
impl Lock { impl Lock {
/// Initialize a Lock, so that it can be used for synchronization. /// Initialize a Lock, so that it can be used for synchronization.
@ -193,6 +198,8 @@ pub struct Condition{
} }
impl SynchObj for Condition {}
impl Condition { impl Condition {
/// Initializes a Condition, so that it can be used for synchronization. /// Initializes a Condition, so that it can be used for synchronization.

View File

@ -15,7 +15,7 @@ pub trait SynchObj { }
/// A method allows to detect of an object corresponding to a given /// A method allows to detect of an object corresponding to a given
/// identifier exists; this is used to check the parameters of system /// identifier exists; this is used to check the parameters of system
/// calls. /// calls.
struct ObjAddr<'a> { pub struct ObjAddr<'a> {
last_id: i32, last_id: i32,
map: HashMap<i32, &'a dyn SynchObj> map: HashMap<i32, &'a dyn SynchObj>
} }