Skip to content

Commit

Permalink
Improve shared rti accesses by replacing mutex with RwLock
Browse files Browse the repository at this point in the history
- Multiple read accesses without any write access are now possible
  and only one write access is allowed for shared rti variables.
  • Loading branch information
chanijjani committed Feb 18, 2024
1 parent 7ba3d49 commit 38dd587
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 224 deletions.
4 changes: 2 additions & 2 deletions rust/rti/src/federate_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ impl FederateInfo {
}
}

pub fn e(&self) -> &SchedulingNode {
pub fn enclave(&self) -> &SchedulingNode {
&self.enclave
}

pub fn enclave(&mut self) -> &mut SchedulingNode {
pub fn enclave_mut(&mut self) -> &mut SchedulingNode {
&mut self.enclave
}

Expand Down
6 changes: 3 additions & 3 deletions rust/rti/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn process_args(rti: &mut RTIRemote, argv: &[String]) -> Result<(), &'static
return Err("Fail to parse a string to i64");
}
};
rti.base()
rti.base_mut()
.set_number_of_scheduling_nodes(num_federates.try_into().unwrap()); // FIXME: panic if the converted value doesn't fit
println!(
"RTI: Number of federates: {}",
Expand Down Expand Up @@ -176,13 +176,13 @@ pub fn initialize_federates(rti: &mut RTIRemote) {
let mut federate = FederateInfo::new();
// FIXME: Handle "as u16" properly.
initialize_federate(&mut federate, i as u16);
let scheduling_nodes: &mut Vec<FederateInfo> = rti.base().scheduling_nodes();
let scheduling_nodes: &mut Vec<FederateInfo> = rti.base_mut().scheduling_nodes_mut();
scheduling_nodes.insert(i as usize, federate);
}
}

fn initialize_federate(fed: &mut FederateInfo, id: u16) {
let enclave = fed.enclave();
let enclave = fed.enclave_mut();
enclave.initialize_scheduling_node(id);
// TODO: fed.set_in_transit_message_tags();
// TODO: fed.set_server_ip_addr();
Expand Down
Loading

0 comments on commit 38dd587

Please sign in to comment.