-}
-
-/* Debug purpose, incomplete */
-void SIMIX_display_process_status(void)
-{
- smx_process_t process = NULL;
- xbt_fifo_item_t item = NULL;
- smx_action_t act;
- int nbprocess = xbt_swag_size(simix_global->process_list);
-
- INFO1("%d processes are still running, waiting for something.", nbprocess);
- /* List the process and their state */
- INFO0
- ("Legend of the following listing: \"<process> on <host>: <status>.\"");
- xbt_swag_foreach(process, simix_global->process_list) {
- char *who, *who2;
-
- asprintf(&who, "%s on %s: %s",
- process->name,
- process->smx_host->name,
- (process->blocked) ? "[BLOCKED] "
- : ((process->suspended) ? "[SUSPENDED] " : ""));
-
- if (process->mutex) {
- who2 =
- bprintf("%s Blocked on mutex %p", who,
- (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
- process->mutex : (void *) 0xdead);
- free(who);
- who = who2;
- } else if (process->cond) {
- who2 =
- bprintf
- ("%s Blocked on condition %p; Waiting for the following actions:",
- who,
- (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
- process->cond : (void *) 0xdead);
- free(who);
- who = who2;
- xbt_fifo_foreach(process->cond->actions, item, act, smx_action_t) {
- who2 =
- bprintf("%s '%s'(%p)", who, act->name,
- (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose))
- ? act : (void *) 0xdead);
- free(who);
- who = who2;
- }
- } else {
- who2 =
- bprintf
- ("%s Blocked in an unknown status (please report this bug)", who);
- free(who);
- who = who2;
- }
- INFO1("%s.", who);
- free(who);
- }
-}
-
-
-/**
- * \brief Launch the SIMIX simulation, debug purpose
- */
-void __SIMIX_main(void)
-{
- smx_process_t process = NULL;
- smx_cond_t cond = NULL;
- smx_action_t smx_action;
- xbt_fifo_t actions_done = xbt_fifo_new();
- xbt_fifo_t actions_failed = xbt_fifo_new();
-
- /* Clean IO before the run */
- fflush(stdout);
- fflush(stderr);
-
- //surf_solve(); /* Takes traces into account. Returns 0.0 */
- /* xbt_fifo_size(msg_global->process_to_run) */
-
- while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
-
- while ((smx_action = xbt_fifo_pop(actions_failed))) {
-
- xbt_fifo_item_t _cursor;
-
- DEBUG1("** %s failed **", smx_action->name);
- xbt_fifo_foreach(smx_action->cond_list, _cursor, cond, smx_cond_t) {
- xbt_swag_foreach(process, cond->sleeping) {
- DEBUG2("\t preparing to wake up %s on %s",
- process->name, process->smx_host->name);
- }
- SIMIX_cond_broadcast(cond);
- /* remove conditional from action */
- SIMIX_unregister_action_to_condition(smx_action, cond);
- }
- }
-
- while ((smx_action = xbt_fifo_pop(actions_done))) {
- xbt_fifo_item_t _cursor;
-
- DEBUG1("** %s done **", smx_action->name);
- xbt_fifo_foreach(smx_action->cond_list, _cursor, cond, smx_cond_t) {
- xbt_swag_foreach(process, cond->sleeping) {
- DEBUG2("\t preparing to wake up %s on %s",
- process->name, process->smx_host->name);
- }
- SIMIX_cond_broadcast(cond);
- /* remove conditional from action */
- SIMIX_unregister_action_to_condition(smx_action, cond);
- }
- }