- surf_solve(); /* Takes traces into account. Returns 0.0 */
-/* xbt_fifo_size(msg_global->process_to_run) */
- while (1) {
- xbt_context_empty_trash();
- while ((process = xbt_fifo_pop(msg_global->process_to_run))) {
-/* fprintf(stderr,"-> %s (%d)\n",process->name, process->simdata->PID); */
- DEBUG3("Scheduling %s(%d) on %s",
- process->name,process->simdata->PID,
- process->simdata->host->name);
- msg_global->current_process = process;
- xbt_context_schedule(process->simdata->context);
- msg_global->current_process = NULL;
- }
- DEBUG1("%lg : Calling surf_solve",MSG_getClock());
- elapsed_time = surf_solve();
- DEBUG1("Elapsed_time %lg",elapsed_time);
-
-/* fprintf(stderr, "====== %lg =====\n",Now); */
-/* if (elapsed_time==0.0) { */
-/* fprintf(stderr, "No change in time\n"); */
-/* } */
- if (elapsed_time<0.0) {
-/* fprintf(stderr, "We're done %lg\n",elapsed_time); */
- break;
- }
-
- {
- surf_action_t action = NULL;
- surf_resource_t resource = NULL;
- m_task_t task = NULL;
-
- xbt_dynar_foreach(resource_list, i, resource) {
- while ((action =
- xbt_swag_extract(resource->common_public->states.
- failed_action_set))) {
- task = action->data;
- if(task) {
- int _cursor;
- DEBUG1("** %s failed **",task->name);
-/* fprintf(stderr,"** %s **\n",task->name); */
- xbt_dynar_foreach(task->simdata->sleeping,_cursor,process) {
- DEBUG3("\t preparing to wake up %s(%d) on %s",
- process->name,process->simdata->PID,
- process->simdata->host->name);
- xbt_fifo_unshift(msg_global->process_to_run, process);
- }
- process=NULL;
- }
- }
- while ((action =
- xbt_swag_extract(resource->common_public->states.
- done_action_set))) {
- task = action->data;
- if(task) {
- int _cursor;
- DEBUG1("** %s done **",task->name);
-/* fprintf(stderr,"** %s **\n",task->name); */
- xbt_dynar_foreach(task->simdata->sleeping,_cursor,process) {
- DEBUG3("\t preparing to wake up %s(%d) on %s",
- process->name,process->simdata->PID,
- process->simdata->host->name);
- xbt_fifo_unshift(msg_global->process_to_run, process);
- }
- process=NULL;
- }
- }
- }
- }
- }
-
- if ((nbprocess=xbt_fifo_size(msg_global->process_list)) == 0) {
- fprintf(stderr,
- "MSG: Congratulations ! Simulation terminated : all process are over\n");
- return MSG_OK;
- } else {
- xbt_fifo_item_t item = NULL;
- fprintf(stderr,"MSG: Oops ! Deadlock or code not perfectly clean.\n");
- fprintf(stderr,"MSG: %d processes are still running, waiting for something.\n",
- nbprocess);
- /* List the process and their state */
- fprintf(stderr,"MSG: <process>(<pid>) on <host>: <status>.\n");
- xbt_fifo_foreach(msg_global->process_list,item,process,m_process_t) {
- simdata_process_t p_simdata = (simdata_process_t) process->simdata;
- simdata_host_t h_simdata=(simdata_host_t)p_simdata->host->simdata;
-
-
- fprintf(stderr,"MSG: %s(%d) on %s: ",
- process->name,p_simdata->PID,
- p_simdata->host->name);
-
- if (process->simdata->blocked)
- fprintf(stderr,"[blocked] ");
- if (process->simdata->suspended)
- fprintf(stderr,"[suspended] ");
-
- for (i=0; i<msg_global->max_channel; i++) {
- if (h_simdata->sleeping[i] == process) {
- fprintf(stderr,"Listening on channel %d.\n",i);
- break;
- }
- }
- if (i==msg_global->max_channel) {
- if(p_simdata->waiting_task) {
- if(p_simdata->waiting_task->simdata->compute) {
- if(p_simdata->put_host)
- fprintf(stderr,"Trying to send a task on Host %s, channel %d.\n",
- p_simdata->put_host->name, p_simdata->put_channel);
- else
- fprintf(stderr,"Waiting for %s to finish.\n",p_simdata->waiting_task->name);
- } else if (p_simdata->waiting_task->simdata->comm)
- fprintf(stderr,"Waiting for %s to be finished transfered.\n",
- p_simdata->waiting_task->name);
- else
- fprintf(stderr,"UNKNOWN STATUS. Please report this bug.\n");
- }
- else { /* Must be trying to put a task somewhere */
- fprintf(stderr,"UNKNOWN STATUS. Please report this bug.\n");
- }
- }
- }
- if(XBT_LOG_ISENABLED(msg, xbt_log_priority_debug) ||
- XBT_LOG_ISENABLED(global, xbt_log_priority_debug)) {
- DEBUG0("Aborting!");
- xbt_abort();
- }
-
- return MSG_WARNING;
- }
-}
-
-/* static void MarkAsFailed(m_task_t t, TBX_HashTable_t failedProcessList) */
-/* { */
-/* simdata_task_t simdata = NULL; */
-/* xbt_fifo_item_t i = NULL; */
-/* m_process_t p = NULL; */
-
-/* xbt_assert0((t!=NULL),"Invalid task"); */
-/* simdata = t->simdata; */
-
-/* #define KILL(task) if(task) SG_failTask(task) */
-/* KILL(simdata->compute); */
-/* KILL(simdata->TCP_comm); */
-/* KILL(simdata->s[0]); */
-/* KILL(simdata->s[1]); */
-/* KILL(simdata->s[2]); */
-/* KILL(simdata->s[3]); */
-/* KILL(simdata->sleep); */
-/* #undef KILL */
-/* /\* if(simdata->comm) SG_failEndToEndTransfer(simdata->comm); *\/ */