Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Compute the user code execution time
[simgrid.git] / src / simix / smx_process.c
index d267eb9..070bfc3 100644 (file)
@@ -434,10 +434,9 @@ smx_action_t SIMIX_process_sleep(smx_process_t process, double duration)
            host->name);
   }
 
-  action = xbt_new0(s_smx_action_t, 1);
+  action = xbt_mallocator_get(simix_global->action_mallocator);
   action->type = SIMIX_ACTION_SLEEP;
-  action->request_list = xbt_fifo_new();
-  action->name = xbt_strdup("sleep");
+  action->name = NULL;
 #ifdef HAVE_TRACING
   action->category = NULL;
 #endif
@@ -454,30 +453,40 @@ smx_action_t SIMIX_process_sleep(smx_process_t process, double duration)
 
 void SIMIX_post_process_sleep(smx_action_t action)
 {
-  e_smx_state_t state = SIMIX_action_map_state(surf_workstation_model->action_state_get(action->sleep.surf_sleep));
   smx_req_t req;
+  e_smx_state_t state;
 
   while ((req = xbt_fifo_shift(action->request_list))) {
+
+    switch(surf_workstation_model->action_state_get(action->sleep.surf_sleep)){
+      case SURF_ACTION_FAILED:
+        state = SIMIX_SRC_HOST_FAILURE;
+        break;
+
+      case SURF_ACTION_DONE:
+        state = SIMIX_DONE;
+        break;
+
+      default:
+        THROW_IMPOSSIBLE;
+        break;
+    }
     req->process_sleep.result = state;
     req->issuer->waiting_action = NULL;
     SIMIX_request_answer(req);
   }
-
   SIMIX_process_sleep_destroy(action);
 }
 
 void SIMIX_process_sleep_destroy(smx_action_t action)
 {
   DEBUG1("Destroy action %p", action);
-  if (action->name)
-    xbt_free(action->name);
   if (action->sleep.surf_sleep)
     action->sleep.surf_sleep->model_type->action_unref(action->sleep.surf_sleep);
 #ifdef HAVE_TRACING
   TRACE_smx_action_destroy(action);
 #endif
-  xbt_fifo_free(action->request_list);
-  xbt_free(action);
+  xbt_mallocator_release(simix_global->action_mallocator, action);
 }
 
 void SIMIX_process_sleep_suspend(smx_action_t action)