- /* Handle any pending timer */
- while (xbt_heap_size(simix_timers) > 0 && SIMIX_get_clock() >= SIMIX_timer_next()) {
- //FIXME: make the timers being real callbacks
- // (i.e. provide dispatchers that read and expand the args)
- timer = (smx_timer_t) xbt_heap_pop(simix_timers);
- if (timer->func)
- timer->func(timer->args);
- xbt_free(timer);
- }
-
- /* Wake up all processes waiting for a Surf action to finish */
- xbt_dynar_foreach(all_existing_models, iter, model) {
- XBT_DEBUG("Handling process whose action failed");
- while ((action = surf_model_extract_failed_action_set(model))) {
- XBT_DEBUG(" Handling Action %p",action);
- SIMIX_simcall_exit((smx_synchro_t) action->getData());
- }
- XBT_DEBUG("Handling process whose action terminated normally");
- while ((action = surf_model_extract_done_action_set(model))) {
- XBT_DEBUG(" Handling Action %p",action);
- if (action->getData() == NULL)
- XBT_DEBUG("probably vcpu's action %p, skip", action);
- else
- SIMIX_simcall_exit((smx_synchro_t) action->getData());
- }
- }
+ // Execute timers and tasks until there isn't anything to be done:
+ bool again = false;
+ do {
+ again = SIMIX_execute_timers();
+ if (SIMIX_execute_tasks())
+ again = true;
+ SIMIX_wake_processes();
+ } while (again);