X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/20d5d4cbcb5580189461745935712009a7afbce5..097a61fa01f109d21c87179ae63061168060905b:/src/simix/smx_process.c diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index c1f19e169a..d3353c2396 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -9,11 +9,12 @@ #include "xbt/log.h" #include "xbt/dict.h" #include "msg/mailbox.h" +#include "mc/mc.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix, "Logging specific to SIMIX (process)"); -static unsigned long simix_process_count = 0; +static unsigned long simix_process_maxpid = 0; /** * \brief Returns the current agent. @@ -24,10 +25,9 @@ static unsigned long simix_process_count = 0; */ XBT_INLINE smx_process_t SIMIX_process_self(void) { - if (simix_global) - return SIMIX_context_get_data(SIMIX_context_self()); + smx_context_t self_context = SIMIX_context_self(); - return NULL; + return self_context ? SIMIX_context_get_data(self_context) : NULL; } /** @@ -76,11 +76,12 @@ void SIMIX_create_maestro_process() /* Create maestro process and intilialize it */ maestro = xbt_new0(s_smx_process_t, 1); - maestro->pid = simix_process_count++; + maestro->pid = simix_process_maxpid++; maestro->name = (char *) ""; maestro->running_ctx = xbt_new(xbt_running_ctx_t, 1); XBT_RUNNING_CTX_INITIALIZE(maestro->running_ctx); maestro->context = SIMIX_context_new(NULL, 0, NULL, NULL, maestro); + maestro->request.issuer = maestro; simix_global->maestro_process = maestro; return; @@ -149,10 +150,9 @@ smx_process_t SIMIX_process_create(const char *name, xbt_assert0(((code != NULL) && (host != NULL)), "Invalid parameters"); /* Process data */ - process->pid = simix_process_count++; + process->pid = simix_process_maxpid++; process->name = xbt_strdup(name); process->smx_host = host; - process->iwannadie = 0; process->data = data; VERB1("Create context %s", process->name); @@ -191,7 +191,7 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t killer) { DEBUG2("Killing process %s on %s", process->name, process->smx_host->name); - process->iwannadie = 1; + process->context->iwannadie = 1; process->blocked = 0; process->suspended = 0; /* FIXME: set doexception to 0 also? */ @@ -214,7 +214,7 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t killer) { break; case SIMIX_ACTION_SYNCHRO: - SIMIX_synchro_stop_waiting(process, process->request); + SIMIX_synchro_stop_waiting(process, &process->request); SIMIX_synchro_destroy(process->waiting_action); break; @@ -343,6 +343,9 @@ void SIMIX_process_resume(smx_process_t process, smx_process_t issuer) } } +int SIMIX_process_get_maxpid(void) { + return simix_process_maxpid; +} int SIMIX_process_count(void) { return xbt_swag_size(simix_global->process_list); @@ -400,7 +403,7 @@ int SIMIX_process_is_suspended(smx_process_t process) int SIMIX_process_is_enabled(smx_process_t process) { - if (process->request && SIMIX_request_is_enabled(process->request)) + if (process->request.call != REQ_NO_REQ && SIMIX_request_is_enabled(&process->request)) return TRUE; return FALSE; @@ -413,12 +416,10 @@ xbt_dict_t SIMIX_process_get_properties(smx_process_t process) void SIMIX_pre_process_sleep(smx_req_t req) { -#ifdef HAVE_MC - if(_surf_do_model_check){ + if (MC_IS_ENABLED) { req->process_sleep.result = SIMIX_DONE; SIMIX_request_answer(req); } -#endif smx_action_t action = SIMIX_process_sleep(req->issuer, req->process_sleep.duration); xbt_fifo_push(action->request_list, req); req->issuer->waiting_action = action; @@ -508,7 +509,7 @@ void SIMIX_process_yield(void) /* Ok, maestro returned control to us */ DEBUG1("Maestro returned control to me: '%s'", self->name); - if (self->iwannadie) + if (self->context->iwannadie) SIMIX_context_stop(self->context); if (self->doexception) { @@ -530,3 +531,10 @@ void SIMIX_process_exception_terminate(xbt_ex_t * e) xbt_ex_display(e); abort(); } + +smx_context_t SIMIX_process_get_context(smx_process_t p) { + return p->context; +} +void SIMIX_process_set_context(smx_process_t p,smx_context_t c) { + p->context = c; +}