Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix: every state should also save a copy of the communication action associated...
[simgrid.git] / src / mc / mc_state.c
index e289fd1..8f88efe 100644 (file)
@@ -49,19 +49,64 @@ int MC_state_process_is_done(mc_state_t state, smx_process_t process){
   return state->proc_status[process->pid].state == MC_DONE ? TRUE : FALSE;
 }
 
-void MC_state_set_executed_request(mc_state_t state, smx_req_t req, unsigned int value)
+void MC_state_set_executed_request(mc_state_t state, smx_req_t req, int value)
 {
-  state->executed_value = value;
-  state->executed = *req;
+  /* The waitany and testany request are transformed into a wait or test request over the
+   * corresponding communication action so it can be treated later by the dependence
+   * function. */
+  switch(req->call){
+    case REQ_COMM_WAITANY:
+      state->internal_req.call = REQ_COMM_WAIT;
+      state->internal_req.issuer = req->issuer;
+      state->internal_comm = *xbt_dynar_get_as(req->comm_waitany.comms, value, smx_action_t);
+      state->internal_req.comm_wait.comm = &state->internal_comm;
+      state->internal_req.comm_wait.timeout = 0;
+      break;
+
+    case REQ_COMM_TESTANY:
+      state->internal_req.call = REQ_COMM_TEST;
+      state->internal_req.issuer = req->issuer;
+
+      if(value > 0)
+        state->internal_comm = *xbt_dynar_get_as(req->comm_testany.comms, value, smx_action_t);
+
+      state->internal_req.comm_wait.comm = &state->internal_comm;
+      state->internal_req.comm_test.result = value;
+      break;
+
+    case REQ_COMM_WAIT:
+      state->internal_req = *req;
+      state->internal_comm = *req->comm_wait.comm;
+      state->internal_req.comm_wait.comm = &state->internal_comm;
+      break;
+
+    case REQ_COMM_TEST:
+      state->internal_req = *req;
+      state->internal_comm = *req->comm_test.comm;
+      state->internal_req.comm_test.comm = &state->internal_comm;
+      break;
+
+    default:
+      state->internal_req = *req;
+      break;
+  }
+
+  state->executed_req = *req;
+  state->req_num = value;
+}
+
+smx_req_t MC_state_get_executed_request(mc_state_t state, int *value)
+{
+  *value = state->req_num;
+  return &state->executed_req;
 }
 
-smx_req_t MC_state_get_executed_request(mc_state_t state, unsigned int *value)
+smx_req_t MC_state_get_internal_request(mc_state_t state)
 {
-  *value = state->executed_value;
-  return &state->executed;
+  return &state->internal_req;
 }
 
-smx_req_t MC_state_get_request(mc_state_t state, unsigned int *value)
+smx_req_t MC_state_get_request(mc_state_t state, int *value)
 {
   smx_process_t process = NULL;
   mc_procstate_t procstate = NULL;
@@ -86,7 +131,7 @@ smx_req_t MC_state_get_request(mc_state_t state, unsigned int *value)
           case REQ_COMM_TESTANY:
             if(MC_request_testany_fail(&process->request)){
               procstate->state = MC_DONE;
-              *value = (unsigned int)-1;
+              *value = -1;
               return &process->request;
             }