Skip to content

Commit

Permalink
Code review: lower case for RTI variables and types.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadliaJerad committed Jun 8, 2023
1 parent 8aaeaaf commit 287a521
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 186 deletions.
20 changes: 10 additions & 10 deletions core/federated/RTI/enclave.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "enclave.h"

/**
* Reference to enclave_RTI_t instance.
* Reference to enclave_rti_t instance.
*/
enclave_RTI_t* _E_RTI;
enclave_rti_t* _e_rti;

// Global variables defined in tag.c:
extern instant_t start_time;
Expand Down Expand Up @@ -49,10 +49,10 @@ void logical_tag_complete(enclave_t* enclave, tag_t completed) {

// Check downstream enclaves to see whether they should now be granted a TAG.
for (int i = 0; i < enclave->num_downstream; i++) {
enclave_t *downstream = _E_RTI->enclaves[enclave->downstream[i]];
enclave_t *downstream = _e_rti->enclaves[enclave->downstream[i]];
// Notify downstream enclave if appropriate.
notify_advance_grant_if_safe(downstream);
bool *visited = (bool *)calloc(_E_RTI->number_of_enclaves, sizeof(bool)); // Initializes to 0.
bool *visited = (bool *)calloc(_e_rti->number_of_enclaves, sizeof(bool)); // Initializes to 0.
// Notify enclaves downstream of downstream if appropriate.
notify_downstream_advance_grant_if_safe(downstream, visited);
free(visited);
Expand All @@ -68,7 +68,7 @@ tag_advance_grant_t tag_advance_grant_if_safe(enclave_t* e) {
tag_t min_upstream_completed = FOREVER_TAG;

for (int j = 0; j < e->num_upstream; j++) {
enclave_t *upstream = _E_RTI->enclaves[e->upstream[j]];
enclave_t *upstream = _e_rti->enclaves[e->upstream[j]];

// Ignore this enclave if it no longer connected.
if (upstream->state == NOT_CONNECTED) continue;
Expand Down Expand Up @@ -99,7 +99,7 @@ tag_advance_grant_t tag_advance_grant_if_safe(enclave_t* e) {

// To handle cycles, need to create a boolean array to keep
// track of which upstream enclave have been visited.
bool *visited = (bool *)calloc(_E_RTI->number_of_enclaves, sizeof(bool)); // Initializes to 0.
bool *visited = (bool *)calloc(_e_rti->number_of_enclaves, sizeof(bool)); // Initializes to 0.

// Find the tag of the earliest possible incoming message from
// upstream enclaves.
Expand All @@ -109,7 +109,7 @@ tag_advance_grant_t tag_advance_grant_if_safe(enclave_t* e) {
NEVER_TAG.time - start_time, 0);

for (int j = 0; j < e->num_upstream; j++) {
enclave_t *upstream = _E_RTI->enclaves[e->upstream[j]];
enclave_t *upstream = _e_rti->enclaves[e->upstream[j]];

// Ignore this enclave if it is no longer connected.
if (upstream->state == NOT_CONNECTED) continue;
Expand Down Expand Up @@ -172,7 +172,7 @@ tag_advance_grant_t tag_advance_grant_if_safe(enclave_t* e) {
void notify_downstream_advance_grant_if_safe(enclave_t* e, bool visited[]) {
visited[e->id] = true;
for (int i = 0; i < e->num_downstream; i++) {
enclave_t* downstream = _E_RTI->enclaves[e->downstream[i]];
enclave_t* downstream = _e_rti->enclaves[e->downstream[i]];
if (visited[downstream->id]) continue;
notify_advance_grant_if_safe(downstream);
notify_downstream_advance_grant_if_safe(downstream, visited);
Expand All @@ -198,7 +198,7 @@ void update_enclave_next_event_tag_locked(enclave_t* e, tag_t next_event_tag) {
// Check downstream enclaves to see whether they should now be granted a TAG.
// To handle cycles, need to create a boolean array to keep
// track of which upstream enclaves have been visited.
bool *visited = (bool *)calloc(_E_RTI->number_of_enclaves, sizeof(bool)); // Initializes to 0.
bool *visited = (bool *)calloc(_e_rti->number_of_enclaves, sizeof(bool)); // Initializes to 0.
notify_downstream_advance_grant_if_safe(e, visited);
free(visited);
}
Expand Down Expand Up @@ -274,7 +274,7 @@ tag_t transitive_next_event(enclave_t* e, tag_t candidate, bool visited[]) {
// an event that would result in an earlier next event.
for (int i = 0; i < e->num_upstream; i++) {
tag_t upstream_result = transitive_next_event(
_E_RTI->enclaves[e->upstream[i]], result, visited);
_e_rti->enclaves[e->upstream[i]], result, visited);

// Add the "after" delay of the connection to the result.
upstream_result = lf_delay_tag(upstream_result, e->upstream_delay[i]);
Expand Down
6 changes: 3 additions & 3 deletions core/federated/RTI/enclave.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ typedef struct enclave_t {
* corresponding enclaves'state.
* // **************** IMPORTANT!!! ********************
* // ** If you make any change to this struct, **
* // ** you MUST also change federation_RTI_t in **
* // ** you MUST also change federation_rti_t in **
* // ** (rti_lib.h)! The change must exactly match. **
* // **************************************************
*/

typedef struct enclave_RTI_t {
typedef struct enclave_rti_t {
// The enclaves.
enclave_t **enclaves;

Expand All @@ -78,7 +78,7 @@ typedef struct enclave_RTI_t {

// Boolean indicating that tracing is enabled.
bool tracing_enabled;
} enclave_RTI_t;
} enclave_rti_t;


/**
Expand Down
4 changes: 2 additions & 2 deletions core/federated/RTI/enclave_impl.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "enclave.h"

// References to the enclave RTI.
extern enclave_RTI_t * _E_RTI;
extern enclave_rti_t * _e_rti;

void notify_tag_advance_grant(enclave_t* e, tag_t tag) {
if (e->state == NOT_CONNECTED
Expand All @@ -10,7 +10,7 @@ void notify_tag_advance_grant(enclave_t* e, tag_t tag) {
) {
return;
}
if (_E_RTI->tracing_enabled) {
if (_e_rti->tracing_enabled) {
tracepoint_RTI_to_federate(send_TAG, e->id, &tag);
}
e->last_granted = tag;
Expand Down
26 changes: 13 additions & 13 deletions core/federated/RTI/rti.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* They both point to the same enclaves stuctures. In the case of federation RTI,
* however, enclaves are encapsulated in federates.
*/
extern enclave_RTI_t * _E_RTI;
extern federation_RTI_t* _F_RTI;
extern enclave_rti_t * _e_rti;
extern federation_rti_t* _f_rti;

/**
* The tracing mechanism uses the number of workers variable `_lf_number_of_workers`.
Expand All @@ -77,7 +77,7 @@ const char *rti_trace_file_name = "rti.lft";
* enabled, before exiting.
*/
void termination() {
if (_F_RTI->tracing_enabled) {
if (_f_rti->tracing_enabled) {
stop_trace();
lf_print("RTI trace file saved.");
}
Expand All @@ -102,26 +102,26 @@ int main(int argc, const char* argv[]) {
// Processing command-line arguments failed.
return -1;
}
if (_F_RTI->tracing_enabled) {
_lf_number_of_workers = _F_RTI->number_of_enclaves;
if (_f_rti->tracing_enabled) {
_lf_number_of_workers = _f_rti->number_of_enclaves;
start_trace(rti_trace_file_name);
lf_print("Tracing the RTI execution in %s file.", rti_trace_file_name);
}

lf_print("Starting RTI for %d federates in federation ID %s.", _F_RTI->number_of_enclaves, _F_RTI->federation_id);
assert(_F_RTI->number_of_enclaves < UINT16_MAX);
lf_print("Starting RTI for %d federates in federation ID %s.", _f_rti->number_of_enclaves, _f_rti->federation_id);
assert(_f_rti->number_of_enclaves < UINT16_MAX);

// Allocate memory for the federates
_F_RTI->enclaves = (federate_t**)calloc(_F_RTI->number_of_enclaves, sizeof(federate_t*));
for (uint16_t i = 0; i < _F_RTI->number_of_enclaves; i++) {
_F_RTI->enclaves[i] = (federate_t *)malloc(sizeof(federate_t));
initialize_federate(_F_RTI->enclaves[i], i);
_f_rti->enclaves = (federate_t**)calloc(_f_rti->number_of_enclaves, sizeof(federate_t*));
for (uint16_t i = 0; i < _f_rti->number_of_enclaves; i++) {
_f_rti->enclaves[i] = (federate_t *)malloc(sizeof(federate_t));
initialize_federate(_f_rti->enclaves[i], i);
}

// Initialize the RTI enclaves
_E_RTI = (enclave_RTI_t*)_F_RTI;
_e_rti = (enclave_rti_t*)_f_rti;

int socket_descriptor = start_rti_server(_F_RTI->user_specified_port);
int socket_descriptor = start_rti_server(_f_rti->user_specified_port);
wait_for_federates(socket_descriptor);

return 0;
Expand Down
Loading

0 comments on commit 287a521

Please sign in to comment.