- 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); */
- msg_global->current_process = process;
- xbt_context_schedule(process->simdata->context);
- msg_global->current_process = NULL;
- }
- Before = MSG_getClock();
- elapsed_time = surf_solve();
- Now = MSG_getClock();
-
-/* fprintf(stderr, "====== %Lg =====\n",Now); */
-/* if (elapsed_time==0.0) { */
-/* fprintf(stderr, "No change in time\n"); */
-/* } */
- if (elapsed_time<0.0) {
- 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;
-/* fprintf(stderr,"** %s **\n",task->name); */
- xbt_dynar_foreach(task->simdata->sleeping,_cursor,process) {
- 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;
-/* fprintf(stderr,"** %s **\n",task->name); */
- xbt_dynar_foreach(task->simdata->sleeping,_cursor,process) {
- 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 {
- 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");
- while ((process=xbt_fifo_pop(msg_global->process_list))) {
- 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);
- 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)
- 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 */
- 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,"UNKNOWN STATUS. Please report this bug.\n");
- }
- }
- }
- }
- return MSG_WARNING;
- }