From: mquinson Date: Mon, 13 Jul 2009 18:04:09 +0000 (+0000) Subject: First running version after the relocation of the context module [Cristian] X-Git-Tag: SVN~1152 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a4aa7f5908948df11fbbc0b6fdf343773c568272?hp=a03bd071f7ec12cf9dd65b0e912fd3f84d29c880 First running version after the relocation of the context module [Cristian] git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6496 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/gras/Virtu/sg_process.c b/src/gras/Virtu/sg_process.c index c001c00fde..218b4473b8 100644 --- a/src/gras/Virtu/sg_process.c +++ b/src/gras/Virtu/sg_process.c @@ -187,7 +187,8 @@ int gras_os_getpid(void) if (process != NULL){ data = (gras_procdata_t *)SIMIX_process_get_data(process); - return data->pid; + if(data != NULL) + return data->pid; } return 0; diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index 64336802d3..9d2059aea2 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -211,7 +211,7 @@ void SIMIX_process_killall() SIMIX_context_empty_trash(); - if (self) { + if (self != simix_global->maestro_process) { SIMIX_context_yield(); } @@ -221,33 +221,35 @@ void SIMIX_process_killall() /** * \brief Clean the SIMIX simulation * - * This functions remove all memories needed to the SIMIX execution + * This functions remove the memory used by SIMIX */ void SIMIX_clean(void) { - smx_process_t p = NULL; - - while ((p = xbt_swag_extract(simix_global->process_list))) { - SIMIX_process_kill(p); - } + /* Kill everyone (except maestro) */ + SIMIX_process_killall(); + /* Destroy the hosts list (and the hosts) */ xbt_dict_free(&(simix_global->host)); + + simix_config_finalize(); + + /* Free the remaining data structures*/ xbt_swag_free(simix_global->process_to_run); + xbt_swag_free(simix_global->process_to_destroy); + xbt_swag_free(simix_global->process_list); + simix_global->process_list = NULL; xbt_dict_free(&(simix_global->registered_functions)); - free(simix_global); - simix_global = NULL; - surf_exit(); + /* Let's free maestro now */ + SIMIX_context_free(simix_global->maestro_process); + free(simix_global->maestro_process); - /*FIXME Remove maestro's smx_process from the process_list before calling - SIMIX_context_mod_exit() and delete it afterwards (it should be the last one) */ + /* Finish context module and SURF */ SIMIX_context_mod_exit(); - xbt_swag_free(simix_global->process_list); - xbt_swag_free(simix_global->process_to_destroy); - - /* Let's free maestro */ - SIMIX_context_free(simix_global->maestro_process); - free(simix_global->maestro_process); + surf_exit(); + + free(simix_global); + simix_global = NULL; return; } @@ -295,12 +297,8 @@ double SIMIX_solve(xbt_fifo_t actions_done, xbt_fifo_t actions_failed) } while ((process = xbt_swag_extract(simix_global->process_to_run))) { - DEBUG2("Scheduling %s on %s", - process->name, process->smx_host->name); - simix_global->current_process = process; + DEBUG2("Scheduling %s on %s", process->name, process->smx_host->name); SIMIX_context_schedule(process); - /* fflush(NULL); */ - simix_global->current_process = NULL; } { diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index fd4a7df6e2..0615265848 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -27,6 +27,7 @@ void SIMIX_process_cleanup(void *arg) { xbt_swag_remove(arg, simix_global->process_to_run); xbt_swag_remove(arg, simix_global->process_list); + xbt_swag_remove(arg, ((smx_process_t)arg)->smx_host->process_list); xbt_swag_insert(arg, simix_global->process_to_destroy); } @@ -49,11 +50,8 @@ void __SIMIX_create_maestro_process() /* Set it as the maestro process */ simix_global->maestro_process = process; + simix_global->current_process = process; - /* Now insert it in the global process list and in the process to run list */ - /* FIXME should it be included in the process_list ??? */ - xbt_swag_insert(process, simix_global->process_list); - return; } @@ -196,9 +194,6 @@ void SIMIX_process_kill(smx_process_t process) if (process->cond) xbt_swag_remove(process, process->cond->sleeping); - xbt_swag_remove(process, simix_global->process_to_run); - xbt_swag_remove(process, simix_global->process_list); - DEBUG2("%p here! killing %p", simix_global->current_process, process); SIMIX_context_kill(process); diff --git a/src/simix/xbt_context.c b/src/simix/xbt_context.c index da0da65d9d..c1f1e656e2 100644 --- a/src/simix/xbt_context.c +++ b/src/simix/xbt_context.c @@ -52,18 +52,12 @@ void SIMIX_context_mod_init(void) void SIMIX_context_mod_exit(void) { if (simix_global->context_factory) { - smx_process_t process = NULL; smx_pfn_context_factory_finalize_t finalize_factory; - /* kill all the processes (except maestro) - * the killed processes are added in the list of the processes to destroy */ + /* if there are living processes then kill them (except maestro) */ + if(simix_global->process_list != NULL) + SIMIX_process_killall(); - while ((process = xbt_swag_extract(simix_global->process_list))) - (*(simix_global->context_factory->kill)) (process); - - /* destroy all processes in the list of process to destroy */ - SIMIX_context_empty_trash(); - /* finalize the context factory */ finalize_factory = simix_global->context_factory->finalize; (*finalize_factory) (&simix_global->context_factory); @@ -234,7 +228,6 @@ void SIMIX_context_empty_trash(void) int i; while ((process = xbt_swag_extract(simix_global->process_to_destroy))){ - free(process->name); process->name = NULL; diff --git a/src/simix/xbt_context_sysv.c b/src/simix/xbt_context_sysv.c index c09153860f..2847201c8d 100644 --- a/src/simix/xbt_context_sysv.c +++ b/src/simix/xbt_context_sysv.c @@ -255,7 +255,7 @@ static void smx_ctx_sysv_suspend(smx_process_t process) DEBUG1("Suspend context: '%s'", simix_global->current_process->name); smx_process_t prev_process = ((xbt_ctx_sysv_t) process->context)->prev; - simix_global->current_process = (smx_process_t) (((xbt_ctx_sysv_t) process->context)->prev); + simix_global->current_process = prev_process; ((xbt_ctx_sysv_t) process->context)->prev = NULL;