- SIMIX_register_action_to_condition(action, request->cond);
-
- for (
- state = SIMIX_action_get_state(action);
- state == SURF_ACTION_READY ||
- state == SURF_ACTION_RUNNING;
- state = SIMIX_action_get_state(action)
- ) {
- SIMIX_cond_wait(request->cond, request->mutex);
- }
-
- SIMIX_unregister_action_to_condition(action, request->cond);
- SIMIX_action_destroy(action);
-
- SIMIX_mutex_unlock(request->mutex);
-
- SIMIX_mutex_lock(smpi_global->received_message_queues_mutexes[dindex]);
- xbt_fifo_push(smpi_global->received_message_queues[dindex], message);
- SIMIX_mutex_unlock(smpi_global->received_message_queues_mutexes[dindex]);
-
- // wake up receiver if necessary
- receiver_process = smpi_global->receiver_processes[dindex];
- if (SIMIX_process_is_suspended(receiver_process)) {
- SIMIX_process_resume(receiver_process);
- }
-
- }
-
- SIMIX_mutex_lock(smpi_global->running_hosts_count_mutex);
- running_hosts_count = smpi_global->running_hosts_count;
- SIMIX_mutex_unlock(smpi_global->running_hosts_count_mutex);
-
- } while (0 < running_hosts_count);
-
- return 0;
+ } else if (mydata->finalize > 0) { /* main wants me to die and nothing to do */
+ DEBUG0("===Main wants me to die and I'm done. Bye, guys.===");
+ mydata->finalize--;
+ SIMIX_cond_signal(mydata->cond);
+ return 0;
+ } else {
+ DEBUG0("Nothing to do. Let's get a nap");
+ SIMIX_process_suspend(self);
+ DEBUG0("===Uh? Someone called me?===");
+ }
+ }
+ return 0;