Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Check if process was suspended while it was sleeping.
[simgrid.git] / src / simix / smx_process.c
index 0fadb63..8378a66 100644 (file)
@@ -742,7 +742,13 @@ void SIMIX_post_process_sleep(smx_action_t action)
     }
     simcall_process_sleep__set__result(simcall, state);
     simcall->issuer->waiting_action = NULL;
-    SIMIX_simcall_answer(simcall);
+    if (simcall->issuer->suspended) {
+      XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
+      simcall->issuer->suspended = 0;
+      SIMIX_pre_process_suspend(simcall, simcall->issuer);
+    } else {
+      SIMIX_simcall_answer(simcall);
+    }
   }
 
   SIMIX_process_sleep_destroy(action);
@@ -766,6 +772,7 @@ void SIMIX_process_sleep_suspend(smx_action_t action)
 
 void SIMIX_process_sleep_resume(smx_action_t action)
 {
+  XBT_DEBUG("Action state is %d on process_sleep_resume.", action->state);
   xbt_assert(action->type == SIMIX_ACTION_SLEEP);
   surf_action_resume(action->sleep.surf_sleep);
 }
@@ -798,10 +805,11 @@ void SIMIX_process_yield(smx_process_t self)
     SIMIX_process_stop(self);
   }
 
-  if(self->suspended) {
+  if (self->suspended) {
+    XBT_DEBUG("Hey! I'm suspended.");
     xbt_assert(!self->doexception, "Gloups! This exception may be lost by subsequent calls.");
     self->suspended = 0;
-    SIMIX_process_suspend(self,self);
+    SIMIX_process_suspend(self, self);
   }
 
   if (self->doexception) {