X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8597d4e91f65d63a0b7c7ec8bf5620adbfa600d1..57b5fe03bd2b4daf9a44cde263ee6f53bc54a948:/src/msg/global.c diff --git a/src/msg/global.c b/src/msg/global.c index 450fd234c1..0da383133a 100644 --- a/src/msg/global.c +++ b/src/msg/global.c @@ -197,6 +197,9 @@ void MSG_paje_output(const char *filename) const char *ext = ".trace"; int ext_len = strlen(ext); int len; + m_host_t host; + m_process_t process; + xbt_fifo_item_t item = NULL; xbt_assert0(msg_global, "Initialize MSG first\n"); xbt_assert0(!msg_global->paje_output, "Paje output already defined\n"); @@ -213,12 +216,23 @@ void MSG_paje_output(const char *filename) fprintf(msg_global->paje_output,"%s",paje_preembule); fprintf(msg_global->paje_output,"%s",type_definitions); + + /* Channels */ for(i=0; imax_channel; i++) { fprintf(msg_global->paje_output, "6 COMM_%d Comm \"Channel %d\"\n" ,i,i); } fprintf(msg_global->paje_output, "7 0.0 CUR Sim_t 0 \"MSG simulation\"\n"); + /* Hosts */ + xbt_fifo_foreach(msg_global->host,item,host,m_host_t) { + PAJE_HOST_NEW(host); + } + + /* Process */ + xbt_fifo_foreach(msg_global->process_list,item,process,m_process_t) { + PAJE_PROCESS_NEW(process); + } } /** \ingroup msg_simulation @@ -311,11 +325,11 @@ MSG_error_t MSG_main(void) 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; + fflush(NULL); xbt_context_schedule(process->simdata->context); msg_global->current_process = NULL; } @@ -336,6 +350,31 @@ MSG_error_t MSG_main(void) surf_action_t action = NULL; surf_resource_t resource = NULL; m_task_t task = NULL; + + void *fun = NULL; + void *arg = NULL; + while (surf_timer_resource->extension_public->get(&fun,(void*)&arg)) { + DEBUG2("got %p %p", fun, arg); + if(fun==MSG_process_create_with_arguments) { + process_arg_t args = arg; + DEBUG2("Launching %s on %s", args->name, args->host->name); + process = MSG_process_create_with_arguments(args->name, args->code, + args->data, args->host, + args->argc,args->argv); + if(args->kill_time > MSG_getClock()) { + surf_timer_resource->extension_public->set(args->kill_time, + (void*) &MSG_process_kill, + (void*) process); + } + xbt_free(args); + } + if(fun==MSG_process_kill) { + process = arg; + DEBUG3("Killing %s(%d) on %s", process->name, process->simdata->PID, + process->simdata->host->name); + MSG_process_kill(process); + } + } xbt_dynar_foreach(resource_list, i, resource) { while ((action = @@ -345,7 +384,6 @@ MSG_error_t MSG_main(void) 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, @@ -362,7 +400,6 @@ MSG_error_t MSG_main(void) 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, @@ -490,16 +527,23 @@ int MSG_process_killall(int reset_PIDs) { xbt_fifo_item_t i = NULL; m_process_t p = NULL; + m_process_t self = MSG_process_self(); while((p=xbt_fifo_shift(msg_global->process_list))) { - MSG_process_kill(p); + if(p!=self) MSG_process_kill(p); } - xbt_context_empty_trash(); + if(reset_PIDs>0) { msg_global->PID = reset_PIDs; msg_global->session++; } + xbt_context_empty_trash(); + + if(self) { + xbt_context_yield(); + } + return msg_global->PID; } @@ -539,8 +583,16 @@ MSG_error_t MSG_clean(void) /** \ingroup msg_easier_life * \brief A clock (in second). + * \deprecated Use MSG_get_clock */ double MSG_getClock(void) { return surf_get_clock(); } +/** \ingroup msg_easier_life + * \brief A clock (in second). + */ +double MSG_get_clock(void) { + return surf_get_clock(); +} +