summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a03bd07)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6496
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
if (process != NULL){
data = (gras_procdata_t *)SIMIX_process_get_data(process);
if (process != NULL){
data = (gras_procdata_t *)SIMIX_process_get_data(process);
+ if(data != NULL)
+ return data->pid;
SIMIX_context_empty_trash();
SIMIX_context_empty_trash();
+ if (self != simix_global->maestro_process) {
/**
* \brief Clean the SIMIX simulation
*
/**
* \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)
{
*/
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));
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_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));
xbt_dict_free(&(simix_global->registered_functions));
- free(simix_global);
- simix_global = NULL;
+ /* 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();
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;
}
while ((process = xbt_swag_extract(simix_global->process_to_run))) {
}
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);
SIMIX_context_schedule(process);
- /* fflush(NULL); */
- simix_global->current_process = NULL;
{
xbt_swag_remove(arg, simix_global->process_to_run);
xbt_swag_remove(arg, simix_global->process_list);
{
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);
}
xbt_swag_insert(arg, simix_global->process_to_destroy);
}
/* Set it as the maestro process */
simix_global->maestro_process = 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);
-
if (process->cond)
xbt_swag_remove(process, process->cond->sleeping);
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);
DEBUG2("%p here! killing %p", simix_global->current_process, process);
SIMIX_context_kill(process);
void SIMIX_context_mod_exit(void)
{
if (simix_global->context_factory) {
void SIMIX_context_mod_exit(void)
{
if (simix_global->context_factory) {
- smx_process_t process = NULL;
smx_pfn_context_factory_finalize_t finalize_factory;
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);
/* finalize the context factory */
finalize_factory = simix_global->context_factory->finalize;
(*finalize_factory) (&simix_global->context_factory);
int i;
while ((process = xbt_swag_extract(simix_global->process_to_destroy))){
int i;
while ((process = xbt_swag_extract(simix_global->process_to_destroy))){
free(process->name);
process->name = NULL;
free(process->name);
process->name = NULL;
DEBUG1("Suspend context: '%s'", simix_global->current_process->name);
smx_process_t prev_process = ((xbt_ctx_sysv_t) process->context)->prev;
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;
((xbt_ctx_sysv_t) process->context)->prev = NULL;