Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Remote support for filling state->internal_comm
[simgrid.git] / src / mc / mc_state.c
index 09b5239..d67fe35 100644 (file)
@@ -20,7 +20,7 @@ static void copy_incomplete_communications_pattern(mc_state_t state) {
   mc_comm_pattern_t comm;
   unsigned int cursor;
   state->incomplete_comm_pattern = xbt_dynar_new(sizeof(xbt_dynar_t), xbt_dynar_free_voidp);
-  for (i=0; i<simix_process_maxpid; i++) {
+  for (i=0; i < MC_smx_get_maxpid(); i++) {
     incomplete_process_comms = xbt_dynar_get_as(incomplete_communications_pattern, i, xbt_dynar_t);
     xbt_dynar_t incomplete_process_comms_copy = xbt_dynar_new(sizeof(mc_comm_pattern_t), comm_pattern_free_voidp);
     xbt_dynar_foreach(incomplete_process_comms, cursor, comm) {
@@ -64,10 +64,8 @@ static void copy_index_communications_pattern(mc_state_t state) {
  */
 mc_state_t MC_state_new()
 {
-  mc_state_t state = NULL;
-
-  state = xbt_new0(s_mc_state_t, 1);
-  state->max_pid = simix_process_maxpid;
+  mc_state_t state = xbt_new0(s_mc_state_t, 1);
+  state->max_pid = MC_smx_get_maxpid();
   state->proc_status = xbt_new0(s_mc_procstate_t, state->max_pid);
   state->system_state = NULL;
   state->num = ++mc_stats->expanded_states;
@@ -146,10 +144,9 @@ void MC_state_set_executed_request(mc_state_t state, smx_simcall_t req,
   case SIMCALL_COMM_WAITANY:
     state->internal_req.call = SIMCALL_COMM_WAIT;
     state->internal_req.issuer = req->issuer;
-    // FIXME, read from remote process
-    state->internal_comm =
-        *xbt_dynar_get_as(simcall_comm_waitany__get__comms(req), value,
-                          smx_synchro_t);
+    MC_process_read_dynar_element(&mc_model_checker->process,
+      &state->internal_comm, simcall_comm_waitany__get__comms(req),
+      sizeof(state->internal_comm));
     simcall_comm_wait__set__comm(&state->internal_req, &state->internal_comm);
     simcall_comm_wait__set__timeout(&state->internal_req, 0);
     break;
@@ -160,9 +157,9 @@ void MC_state_set_executed_request(mc_state_t state, smx_simcall_t req,
 
     if (value > 0)
       // FIXME, read from remote process
-      state->internal_comm =
-          *xbt_dynar_get_as(simcall_comm_testany__get__comms(req), value,
-                            smx_synchro_t);
+        MC_process_read_dynar_element(&mc_model_checker->process,
+          &state->internal_comm, simcall_comm_testany__get__comms(req),
+          sizeof(state->internal_comm));
 
     simcall_comm_test__set__comm(&state->internal_req, &state->internal_comm);
     simcall_comm_test__set__result(&state->internal_req, value);
@@ -170,16 +167,16 @@ void MC_state_set_executed_request(mc_state_t state, smx_simcall_t req,
 
   case SIMCALL_COMM_WAIT:
     state->internal_req = *req;
-    // FIXME, read from remote process
-    state->internal_comm = *(simcall_comm_wait__get__comm(req));
+    MC_process_read_simple(&mc_model_checker->process, &state->internal_comm ,
+      simcall_comm_wait__get__comm(req), sizeof(state->internal_comm));
     simcall_comm_wait__set__comm(&state->executed_req, &state->internal_comm);
     simcall_comm_wait__set__comm(&state->internal_req, &state->internal_comm);
     break;
 
   case SIMCALL_COMM_TEST:
     state->internal_req = *req;
-    // FIXME, read from remote process
-    state->internal_comm = *simcall_comm_test__get__comm(req);
+    MC_process_read_simple(&mc_model_checker->process, &state->internal_comm,
+      simcall_comm_test__get__comm(req), sizeof(state->internal_comm));
     simcall_comm_test__set__comm(&state->executed_req, &state->internal_comm);
     simcall_comm_test__set__comm(&state->internal_req, &state->internal_comm);
     break;
@@ -226,10 +223,13 @@ smx_simcall_t MC_state_get_request(mc_state_t state, int *value)
   MC_EACH_SIMIX_PROCESS(process,
     procstate = &state->proc_status[process->pid];
 
-    if (procstate->state == MC_INTERLEAVE
-        || procstate->state == MC_MORE_INTERLEAVE) {
-      if (MC_process_is_enabled(process)) {
-        switch (process->simcall.call) {
+    if (procstate->state != MC_INTERLEAVE
+        && procstate->state != MC_MORE_INTERLEAVE)
+        continue;
+    if (!MC_process_is_enabled(process))
+      continue;
+
+    switch (process->simcall.call) {
         case SIMCALL_COMM_WAITANY:
           *value = -1;
           while (procstate->interleave_count <
@@ -307,8 +307,7 @@ smx_simcall_t MC_state_get_request(mc_state_t state, int *value)
           *value = 0;
           return &process->simcall;
           break;
-        }
-      }
+
     }
   );