Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
made some changes to allow more than one DO_ONCE block. also fixed bug in
[simgrid.git] / src / smpi / smpi_util.c
index 60f4157..ac5d372 100644 (file)
@@ -18,28 +18,24 @@ int smpi_gettimeofday(struct timeval *tv, struct timezone *tz)
 
 unsigned int smpi_sleep(unsigned int seconds)
 {
-       smx_mutex_t mutex;
-       smx_cond_t cond;
        smx_host_t host;
        smx_action_t action;
 
        smpi_bench_end();
-       host   = SIMIX_host_self();
-       action = SIMIX_action_sleep(host, seconds);
-       mutex  = SIMIX_mutex_init();
-       cond   = SIMIX_cond_init();
 
-       SIMIX_mutex_lock(mutex);
-       SIMIX_register_action_to_condition(action, cond);
-       SIMIX_cond_wait(cond, mutex);
-       SIMIX_unregister_action_to_condition(action, cond);
-       SIMIX_mutex_unlock(mutex);
+       host  = SIMIX_host_self();
+
+       SIMIX_mutex_lock(smpi_global->execute_mutex);
+
+       // FIXME: explicit conversion to double?
+       action = SIMIX_action_sleep(host, seconds);
 
-       SIMIX_mutex_destroy(mutex);
-       SIMIX_cond_destroy(cond);
-       //SIMIX_action_destroy(action);
+       SIMIX_register_action_to_condition(action, smpi_global->execute_cond);
+       SIMIX_cond_wait(smpi_global->execute_cond, smpi_global->execute_mutex);
+       SIMIX_unregister_action_to_condition(action, smpi_global->execute_cond);
+       SIMIX_action_destroy(action);
 
-       // FIXME: check for success/failure?
+       SIMIX_mutex_unlock(smpi_global->execute_mutex);
 
        smpi_bench_begin();
        return 0;