X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/581f7e0bfc3cae71b1e7c39a0c6af6b790e7b0a2..f4a258218681d1002c99d4556ba4b21bc6a6adff:/src/msg/global.c diff --git a/src/msg/global.c b/src/msg/global.c index 32967aed1a..26faad1ae1 100644 --- a/src/msg/global.c +++ b/src/msg/global.c @@ -8,8 +8,9 @@ #include "private.h" #include "xbt/sysdep.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(global, msg, - "Logging specific to MSG (global)"); +#include "xbt/ex.h" /* ex_backtrace_display */ +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, + "Logging specific to MSG (kernel)"); int __stop_at_time = -1.0 ; @@ -22,6 +23,7 @@ MSG_Global_t msg_global = NULL; * \brief This section describes the functions you need to know to * set up a simulation. You should have a look at \ref MSG_examples * to have an overview of their usage. + * \htmlonly \endhtmlonly */ /********************************* MSG **************************************/ @@ -52,6 +54,10 @@ void MSG_global_init(int *argc, char **argv) msg_global->current_process = NULL; msg_global->registered_functions = xbt_dict_new(); msg_global->PID = 1; + msg_global->task_mallocator = xbt_mallocator_new(256, + (pvoid_f_void_t*) task_mallocator_new_f, + (void_f_pvoid_t*) task_mallocator_free_f, + (void_f_pvoid_t*) task_mallocator_reset_f); } } @@ -142,6 +148,7 @@ void MSG_paje_output(const char *filename) "% EntityType string\n" "% Container string\n" "% Value string\n" + "% TaskName string\n" "%EndEventDef\n" "%EventDef PajePopState 12\n" "% Time date\n" @@ -205,7 +212,7 @@ void MSG_paje_output(const char *filename) len = strlen(filename); if((len \endhtmlonly + * * * For convenience, the simulator provides the notion of channel * that is close to the tag notion in MPI. A channel is not a @@ -277,15 +286,84 @@ int MSG_get_channel_number(void) return msg_global->max_channel; } +void __MSG_display_process_status(void) +{ + m_process_t process = NULL; + xbt_fifo_item_t item = NULL; + int i; + int nbprocess=xbt_fifo_size(msg_global->process_list); + + INFO1("MSG: %d processes are still running, waiting for something.", + nbprocess); + /* List the process and their state */ + INFO0("MSG: () on : ."); + 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; + char *who; + + asprintf(&who,"MSG: %s(%d) on %s: %s", + process->name,p_simdata->PID, + p_simdata->host->name, + (process->simdata->blocked)?"[blocked] " + :((process->simdata->suspended)?"[suspended] ":"")); + + for (i=0; imax_channel; i++) { + if (h_simdata->sleeping[i] == process) { + INFO2("%s\tListening on channel %d",who,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) { + INFO4("%s\tTrying to send the task '%s' to Host %s, channel %d.", + who, p_simdata->waiting_task->name,p_simdata->put_host->name, p_simdata->put_channel); + } else { + INFO2("%s\tWaiting for %s to finish.",who,p_simdata->waiting_task->name); + } + } else if (p_simdata->waiting_task->simdata->comm) { + INFO2("%s\tWaiting for %s to be finished transfered.", + who,p_simdata->waiting_task->name); + } else { + INFO1("%s\tUNKNOWN STATUS. Please report this bug.",who); + } +/* The following would display the trace of where the maestro thread is, + since this is the thread calling this. I'd like to get the other threads to + run this to see where they were blocked, but I'm not sure of how to do this */ +/* xbt_backtrace_display(); */ + } else { /* Must be trying to put a task somewhere */ + INFO1("%s\tUNKNOWN STATUS. Please report this bug.",who); + } + } + free(who); + } +} + +/* FIXME: Yeah, I'll do it in a portable maner one day [Mt] */ +#include + +static void inthandler(int ignored) +{ + INFO0("CTRL-C pressed. Displaying status and bailing out"); + __MSG_display_process_status(); + exit(1); +} + /** \ingroup msg_simulation * \brief Launch the MSG simulation */ MSG_error_t MSG_main(void) { m_process_t process = NULL; - int nbprocess,i; + int i; double elapsed_time = 0.0; int state_modifications = 1; + + /* Prepare to display some more info when dying on Ctrl-C pressing */ + signal(SIGINT,inthandler); + /* Clean IO before the run */ fflush(stdout); fflush(stderr); @@ -302,7 +380,7 @@ MSG_error_t MSG_main(void) } while ((process = xbt_fifo_pop(msg_global->process_to_run))) { - DEBUG3("Scheduling %s(%d) on %s", + DEBUG3("Scheduling %s(%d) on %s", process->name,process->simdata->PID, process->simdata->host->name); msg_global->current_process = process; @@ -326,9 +404,9 @@ MSG_error_t MSG_main(void) } if(!state_modifications) { - DEBUG1("%g : Calling surf_solve",MSG_get_clock()); + DEBUG1("%f : Calling surf_solve",MSG_get_clock()); elapsed_time = surf_solve(); - DEBUG1("Elapsed_time %g",elapsed_time); + DEBUG1("Elapsed_time %f",elapsed_time); if (elapsed_time<0.0) { /* fprintf(stderr, "We're done %g\n",elapsed_time); */ @@ -397,54 +475,14 @@ MSG_error_t MSG_main(void) state_modifications = 0; } - if ((nbprocess=xbt_fifo_size(msg_global->process_list)) == 0) { - INFO0("Congratulations ! Simulation terminated : all process are over"); + if (xbt_fifo_size(msg_global->process_list) == 0) { + INFO0("Congratulations ! Simulation terminated : all processes are over"); return MSG_OK; } else { - xbt_fifo_item_t item = NULL; INFO0("Oops ! Deadlock or code not perfectly clean."); - INFO1("MSG: %d processes are still running, waiting for something.", - nbprocess); - /* List the process and their state */ - INFO0("MSG: () on : ."); - 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; - - - INFO4("MSG: %s(%d) on %s: %s", - process->name,p_simdata->PID, - p_simdata->host->name, - (process->simdata->blocked)?"[blocked] " - :((process->simdata->suspended)?"[suspended] ":"")); - - for (i=0; imax_channel; i++) { - if (h_simdata->sleeping[i] == process) { - INFO1("\tListening on channel %d.",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) - INFO2("\tTrying to send a task to Host %s, channel %d.", - p_simdata->put_host->name, p_simdata->put_channel); - else - INFO1("Waiting for %s to finish.",p_simdata->waiting_task->name); - } else if (p_simdata->waiting_task->simdata->comm) - INFO1("Waiting for %s to be finished transfered.", - p_simdata->waiting_task->name); - else - INFO0("UNKNOWN STATUS. Please report this bug."); - } - else { /* Must be trying to put a task somewhere */ - INFO0("UNKNOWN STATUS. Please report this bug."); - } - } - } + __MSG_display_process_status(); if(XBT_LOG_ISENABLED(msg, xbt_log_priority_debug) || - XBT_LOG_ISENABLED(global, xbt_log_priority_debug)) { + XBT_LOG_ISENABLED(msg_kernel, xbt_log_priority_debug)) { DEBUG0("Aborting!"); xbt_abort(); } @@ -466,7 +504,7 @@ int MSG_process_killall(int reset_PIDs) m_process_t p = NULL; m_process_t self = MSG_process_self(); - while((p=xbt_fifo_shift(msg_global->process_list))) { + while((p=xbt_fifo_pop(msg_global->process_list))) { if(p!=self) MSG_process_kill(p); } @@ -494,7 +532,7 @@ MSG_error_t MSG_clean(void) m_process_t p = NULL; - while((p=xbt_fifo_shift(msg_global->process_list))) { + while((p=xbt_fifo_pop(msg_global->process_list))) { MSG_process_kill(p); } xbt_context_exit(); @@ -506,6 +544,7 @@ MSG_error_t MSG_clean(void) xbt_fifo_free(msg_global->process_to_run); xbt_fifo_free(msg_global->process_list); xbt_dict_free(&(msg_global->registered_functions)); + xbt_mallocator_free(msg_global->task_mallocator); if(msg_global->paje_output) { fclose(msg_global->paje_output);