XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
"Logging specific to SIMIX (process)");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
"Logging specific to SIMIX (process)");
void SIMIX_process_cleanup(smx_process_t process)
{
DEBUG1("Cleanup process %s", process->name);
void SIMIX_process_cleanup(smx_process_t process)
{
DEBUG1("Cleanup process %s", process->name);
xbt_swag_remove(process, simix_global->process_list);
xbt_swag_remove(process, process->smx_host->process_list);
xbt_swag_insert(process, simix_global->process_to_destroy);
xbt_swag_remove(process, simix_global->process_list);
xbt_swag_remove(process, process->smx_host->process_list);
xbt_swag_insert(process, simix_global->process_to_destroy);
/* Create maestro process and intilialize it */
maestro = xbt_new0(s_smx_process_t, 1);
/* Create maestro process and intilialize it */
maestro = xbt_new0(s_smx_process_t, 1);
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->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);
-smx_process_t SIMIX_process_create(const char *name,
- xbt_main_func_t code,
- void *data,
- const char *hostname,
- int argc, char **argv,
- xbt_dict_t properties) {
-
- smx_process_t process = NULL;
+void SIMIX_process_create(smx_process_t *process,
+ const char *name,
+ xbt_main_func_t code,
+ void *data,
+ const char *hostname,
+ int argc, char **argv,
+ xbt_dict_t properties) {
+
+ *process = NULL;
smx_host_t host = SIMIX_host_get_by_name(hostname);
DEBUG2("Start process %s on host %s", name, hostname);
smx_host_t host = SIMIX_host_get_by_name(hostname);
DEBUG2("Start process %s on host %s", name, hostname);
- process->pid = simix_process_count++;
- process->name = xbt_strdup(name);
- process->smx_host = host;
- process->iwannadie = 0;
- process->data = data;
+ (*process)->pid = simix_process_maxpid++;
+ (*process)->name = xbt_strdup(name);
+ (*process)->smx_host = host;
+ (*process)->data = data;
- VERB1("Create context %s", process->name);
- process->context = SIMIX_context_new(code, argc, argv,
- simix_global->cleanup_process_function, process);
+ VERB1("Create context %s", (*process)->name);
+ (*process)->context = SIMIX_context_new(code, argc, argv,
+ simix_global->cleanup_process_function, *process);
- process->running_ctx = xbt_new(xbt_running_ctx_t, 1);
- XBT_RUNNING_CTX_INITIALIZE(process->running_ctx);
+ (*process)->running_ctx = xbt_new(xbt_running_ctx_t, 1);
+ XBT_RUNNING_CTX_INITIALIZE((*process)->running_ctx);
- xbt_swag_insert(process, simix_global->process_list);
- DEBUG2("Inserting %s(%s) in the to_run list", process->name, host->name);
- xbt_swag_insert(process, simix_global->process_to_run);
+ xbt_swag_insert(*process, simix_global->process_list);
+ DEBUG2("Inserting %s(%s) in the to_run list", (*process)->name, host->name);
+ xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, *process);
while ((p = xbt_swag_extract(simix_global->process_list)))
SIMIX_process_kill(p, SIMIX_process_self());
while ((p = xbt_swag_extract(simix_global->process_list)))
SIMIX_process_kill(p, SIMIX_process_self());
}
smx_action_t action = SIMIX_process_sleep(req->issuer, req->process_sleep.duration);
xbt_fifo_push(action->request_list, req);
}
smx_action_t action = SIMIX_process_sleep(req->issuer, req->process_sleep.duration);
xbt_fifo_push(action->request_list, req);
req->process_sleep.result = state;
req->issuer->waiting_action = NULL;
SIMIX_request_answer(req);
}
req->process_sleep.result = state;
req->issuer->waiting_action = NULL;
SIMIX_request_answer(req);
}
/* Ok, maestro returned control to us */
DEBUG1("Maestro returned control to me: '%s'", self->name);
/* Ok, maestro returned control to us */
DEBUG1("Maestro returned control to me: '%s'", self->name);