1 /* Copyright (c) 2007-2012. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "smx_private.h"
8 #include "xbt/sysdep.h"
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
14 "Logging specific to SIMIX (process)");
16 unsigned long simix_process_maxpid = 0;
19 * \brief Returns the current agent.
21 * This functions returns the currently running SIMIX process.
23 * \return The SIMIX process
25 XBT_INLINE smx_process_t SIMIX_process_self(void)
27 smx_context_t self_context = SIMIX_context_self();
29 return self_context ? SIMIX_context_get_data(self_context) : NULL;
33 * \brief Returns whether a process has pending asynchronous communications.
34 * \return true if there are asynchronous communications in this process
36 int SIMIX_process_has_pending_comms(smx_process_t process) {
38 return xbt_fifo_size(process->comms) > 0;
41 void SIMIX_pre_process_cleanup(smx_simcall_t simcall, smx_process_t process) {
42 SIMIX_process_cleanup(process);
45 * \brief Moves a process to the list of processes to destroy.
47 void SIMIX_process_cleanup(smx_process_t process)
49 XBT_DEBUG("Cleanup process %s (%p), waiting action %p",
50 process->name, process, process->waiting_action);
52 /* cancel non-blocking communications */
54 while ((action = xbt_fifo_pop(process->comms))) {
56 /* make sure no one will finish the comm after this process is destroyed,
57 * because src_proc or dst_proc would be an invalid pointer */
58 SIMIX_comm_cancel(action);
60 if (action->comm.src_proc == process) {
61 XBT_DEBUG("Found an unfinished send comm %p (detached = %d), state %d, src = %p, dst = %p",
62 action, action->comm.detached, (int)action->state, action->comm.src_proc, action->comm.dst_proc);
63 action->comm.src_proc = NULL;
65 if (action->comm.detached) {
66 if (action->comm.refcount == 0) {
67 XBT_DEBUG("Increase the refcount before destroying it since it's detached");
68 /* I'm not supposed to destroy a detached comm from the sender side,
69 * unless there is no receiver matching the rdv */
70 action->comm.refcount++;
71 SIMIX_comm_destroy(action);
74 XBT_DEBUG("Don't destroy it since its refcount is %d", action->comm.refcount);
77 SIMIX_comm_destroy(action);
80 else if (action->comm.dst_proc == process){
81 XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p",
82 action, (int)action->state, action->comm.src_proc, action->comm.dst_proc);
83 action->comm.dst_proc = NULL;
85 if (action->comm.detached && action->comm.refcount == 1
86 && action->comm.src_proc != NULL) {
87 /* the comm will be freed right now, remove it from the sender */
88 xbt_fifo_remove(action->comm.src_proc->comms, action);
90 SIMIX_comm_destroy(action);
93 xbt_die("Communication action %p is in my list but I'm not the sender "
94 "or the receiver", action);
98 /*xbt_swag_remove(process, simix_global->process_to_run);*/
99 xbt_swag_remove(process, simix_global->process_list);
100 xbt_swag_remove(process, process->smx_host->process_list);
101 xbt_swag_insert(process, simix_global->process_to_destroy);
102 process->context->iwannadie = 0;
108 * Should be called some time to time to free the memory allocated for processes
109 * that have finished (or killed).
111 void SIMIX_process_empty_trash(void)
113 smx_process_t process = NULL;
115 while ((process = xbt_swag_extract(simix_global->process_to_destroy))) {
116 SIMIX_context_free(process->context);
118 /* Free the exception allocated at creation time */
119 free(process->running_ctx);
120 xbt_dict_free(&process->properties);
122 xbt_fifo_free(process->comms);
124 xbt_dynar_free(&process->on_exit);
132 * \brief Creates and runs the maestro process
134 void SIMIX_create_maestro_process()
136 smx_process_t maestro = NULL;
138 /* Create maestro process and intilialize it */
139 maestro = xbt_new0(s_smx_process_t, 1);
140 maestro->pid = simix_process_maxpid++;
141 maestro->name = (char *) "";
142 maestro->running_ctx = xbt_new(xbt_running_ctx_t, 1);
143 XBT_RUNNING_CTX_INITIALIZE(maestro->running_ctx);
144 maestro->context = SIMIX_context_new(NULL, 0, NULL, NULL, maestro);
145 maestro->simcall.issuer = maestro;
147 simix_global->maestro_process = maestro;
151 * \brief Stops a process.
153 * Stops the process, execute all the registered on_exit functions,
154 * register it to the list of the process to restart if needed
155 * and stops its context.
157 void SIMIX_process_stop(smx_process_t arg) {
158 /* execute the on_exit functions */
159 SIMIX_process_on_exit_runall(arg);
160 /* Add the process to the list of process to restart, only if
163 if (arg->auto_restart && !SIMIX_host_get_state(arg->smx_host)) {
164 SIMIX_host_add_auto_restart_process(arg->smx_host,arg->name,arg->code, arg->data,
167 arg->argc,arg->argv,arg->properties,
170 XBT_DEBUG("Process %s (%s) is dead",arg->name,arg->smx_host->name);
171 /* stop the context */
172 SIMIX_context_stop(arg->context);
176 * \brief Same as SIMIX_process_create() but with only one argument (used by timers).
177 * This function frees the argument.
178 * \return the process created
180 smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) {
182 smx_process_t process;
183 simix_global->create_process_function(
199 void SIMIX_pre_process_create(smx_simcall_t simcall,
200 smx_process_t *process,
202 xbt_main_func_t code,
204 const char *hostname,
206 int argc, char **argv,
207 xbt_dict_t properties,
209 return SIMIX_process_create(process, name, code, data, hostname,
210 kill_time, argc, argv, properties, auto_restart);
213 * \brief Internal function to create a process.
215 * This function actually creates the process.
216 * It may be called when a SIMCALL_PROCESS_CREATE simcall occurs,
217 * or directly for SIMIX internal purposes. The sure thing is that it's called from maestro context.
219 * \return the process created
221 void SIMIX_process_create(smx_process_t *process,
223 xbt_main_func_t code,
225 const char *hostname,
227 int argc, char **argv,
228 xbt_dict_t properties,
232 smx_host_t host = SIMIX_host_get_by_name(hostname);
234 XBT_DEBUG("Start process %s on host '%s'", name, hostname);
236 if (!SIMIX_host_get_state(host)) {
237 XBT_WARN("Cannot launch process '%s' on failed host '%s'", name,
241 *process = xbt_new0(s_smx_process_t, 1);
243 xbt_assert(((code != NULL) && (host != NULL)), "Invalid parameters");
245 (*process)->pid = simix_process_maxpid++;
246 (*process)->name = xbt_strdup(name);
247 (*process)->smx_host = host;
248 (*process)->data = data;
249 (*process)->comms = xbt_fifo_new();
250 (*process)->simcall.issuer = *process;
251 /* Process data for auto-restart */
252 (*process)->auto_restart = auto_restart;
253 (*process)->code = code;
254 (*process)->argc = argc;
255 (*process)->argv = argv;
256 (*process)->kill_time = kill_time;
259 XBT_VERB("Create context %s", (*process)->name);
260 (*process)->context = SIMIX_context_new(code, argc, argv,
261 simix_global->cleanup_process_function, *process);
263 (*process)->running_ctx = xbt_new(xbt_running_ctx_t, 1);
264 XBT_RUNNING_CTX_INITIALIZE((*process)->running_ctx);
267 (*process)->properties = properties;
269 /* Add the process to it's host process list */
270 xbt_swag_insert(*process, host->process_list);
272 XBT_DEBUG("Start context '%s'", (*process)->name);
274 /* Now insert it in the global process list and in the process to run list */
275 xbt_swag_insert(*process, simix_global->process_list);
276 XBT_DEBUG("Inserting %s(%s) in the to_run list", (*process)->name, host->name);
277 xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, *process);
280 if (kill_time > SIMIX_get_clock()) {
281 if (simix_global->kill_process_function) {
282 XBT_DEBUG("Process %s(%s) will be kill at time %f", (*process)->name,
283 (*process)->smx_host->name, kill_time);
284 SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process);
290 * \brief Executes the processes from simix_global->process_to_run.
292 * The processes of simix_global->process_to_run are run (in parallel if
293 * possible). On exit, simix_global->process_to_run is empty, and
294 * simix_global->process_that_ran contains the list of processes that just ran.
295 * The two lists are swapped so, be careful when using them before and after a
296 * call to this function.
298 void SIMIX_process_runall(void)
300 SIMIX_context_runall();
302 xbt_dynar_t tmp = simix_global->process_that_ran;
303 simix_global->process_that_ran = simix_global->process_to_run;
304 simix_global->process_to_run = tmp;
305 xbt_dynar_reset(simix_global->process_to_run);
308 void SIMIX_pre_process_kill(smx_simcall_t simcall, smx_process_t process) {
309 SIMIX_process_kill(process, simcall->issuer);
312 * \brief Internal function to kill a SIMIX process.
314 * This function may be called when a SIMCALL_PROCESS_KILL simcall occurs,
315 * or directly for SIMIX internal purposes.
317 * \param process poor victim
318 * \param issuer the process which has sent the PROCESS_KILL. Important to not schedule twice the same process.
320 void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) {
322 XBT_DEBUG("Killing process %s on %s", process->name, process->smx_host->name);
324 process->context->iwannadie = 1;
325 process->blocked = 0;
326 process->suspended = 0;
327 /* FIXME: set doexception to 0 also? */
329 /* destroy the blocking action if any */
330 if (process->waiting_action) {
332 switch (process->waiting_action->type) {
334 case SIMIX_ACTION_EXECUTE:
335 case SIMIX_ACTION_PARALLEL_EXECUTE:
336 SIMIX_host_execution_destroy(process->waiting_action);
339 case SIMIX_ACTION_COMMUNICATE:
340 xbt_fifo_remove(process->comms, process->waiting_action);
341 SIMIX_comm_cancel(process->waiting_action);
344 case SIMIX_ACTION_SLEEP:
345 SIMIX_process_sleep_destroy(process->waiting_action);
348 case SIMIX_ACTION_SYNCHRO:
349 SIMIX_synchro_stop_waiting(process, &process->simcall);
350 SIMIX_synchro_destroy(process->waiting_action);
353 case SIMIX_ACTION_IO:
354 SIMIX_io_destroy(process->waiting_action);
357 /* **************************************/
358 /* TUTORIAL: New API */
359 case SIMIX_ACTION_NEW_API:
360 SIMIX_new_api_destroy(process->waiting_action);
362 /* **************************************/
366 if(!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != issuer) {
367 xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
372 void SIMIX_pre_process_killall(smx_simcall_t simcall) {
373 SIMIX_process_killall(simcall->issuer);
376 * \brief Kills all running processes.
377 * \param issuer this one will not be killed
379 void SIMIX_process_killall(smx_process_t issuer)
381 smx_process_t p = NULL;
383 while ((p = xbt_swag_extract(simix_global->process_list))) {
385 SIMIX_process_kill(p,issuer);
389 SIMIX_context_runall();
391 SIMIX_process_empty_trash();
394 void SIMIX_pre_process_change_host(smx_simcall_t simcall, smx_process_t process,
397 process->new_host = dest;
399 void SIMIX_process_change_host(smx_process_t process,
402 xbt_assert((process != NULL), "Invalid parameters");
403 xbt_swag_remove(process, process->smx_host->process_list);
404 process->smx_host = dest;
405 xbt_swag_insert(process, dest->process_list);
409 void SIMIX_pre_process_suspend(smx_simcall_t simcall, smx_process_t process)
411 smx_action_t action_suspend =
412 SIMIX_process_suspend(process, simcall->issuer);
414 if (process != simcall->issuer) {
415 SIMIX_simcall_answer(simcall);
417 xbt_fifo_push(action_suspend->simcalls, simcall);
418 process->waiting_action = action_suspend;
419 SIMIX_host_execution_suspend(process->waiting_action);
421 /* If we are suspending ourselves, then just do not finish the simcall now */
424 smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer)
426 xbt_assert((process != NULL), "Invalid parameters");
428 if (process->suspended) {
429 XBT_DEBUG("Process '%s' is already suspended", process->name);
433 process->suspended = 1;
435 /* If we are suspending another process, and it is waiting on an action,
436 suspend its action. */
437 if (process != issuer) {
439 if (process->waiting_action) {
441 switch (process->waiting_action->type) {
443 case SIMIX_ACTION_EXECUTE:
444 case SIMIX_ACTION_PARALLEL_EXECUTE:
445 SIMIX_host_execution_suspend(process->waiting_action);
448 case SIMIX_ACTION_COMMUNICATE:
449 SIMIX_comm_suspend(process->waiting_action);
452 case SIMIX_ACTION_SLEEP:
453 SIMIX_process_sleep_suspend(process->waiting_action);
456 case SIMIX_ACTION_SYNCHRO:
457 /* Suspension is delayed to when the process is rescheduled. */
461 xbt_die("Internal error in SIMIX_process_suspend: unexpected action type %d",
462 (int)process->waiting_action->type);
466 /* Suspension is delayed to when the process is rescheduled. */
470 return SIMIX_host_execute("suspend", process->smx_host, 0.0, 1.0);
474 void SIMIX_pre_process_resume(smx_simcall_t simcall, smx_process_t process){
475 SIMIX_process_resume(process, simcall->issuer);
478 void SIMIX_process_resume(smx_process_t process, smx_process_t issuer)
480 xbt_assert((process != NULL), "Invalid parameters");
482 XBT_IN("process = %p, issuer = %p", process, issuer);
484 if(process->context->iwannadie) {
485 XBT_VERB("Ignoring request to suspend a process that is currently dying.");
489 if(!process->suspended) return;
490 process->suspended = 0;
492 /* If we are resuming another process, resume the action it was waiting for
493 if any. Otherwise add it to the list of process to run in the next round. */
494 if (process != issuer) {
496 if (process->waiting_action) {
498 switch (process->waiting_action->type) {
500 case SIMIX_ACTION_EXECUTE:
501 case SIMIX_ACTION_PARALLEL_EXECUTE:
502 SIMIX_host_execution_resume(process->waiting_action);
505 case SIMIX_ACTION_COMMUNICATE:
506 SIMIX_comm_resume(process->waiting_action);
509 case SIMIX_ACTION_SLEEP:
510 SIMIX_process_sleep_resume(process->waiting_action);
513 case SIMIX_ACTION_SYNCHRO:
514 /* I cannot resume it now. This is delayed to when the process is rescheduled at
515 * the end of the synchro. */
519 xbt_die("Internal error in SIMIX_process_resume: unexpected action type %d",
520 (int)process->waiting_action->type);
523 } else XBT_WARN("Strange. Process %p is trying to resume himself.", issuer);
528 int SIMIX_process_get_maxpid(void) {
529 return simix_process_maxpid;
532 int SIMIX_pre_process_count(smx_simcall_t simcall){
533 return SIMIX_process_count();
535 int SIMIX_process_count(void)
537 return xbt_swag_size(simix_global->process_list);
540 void* SIMIX_pre_process_self_get_data(smx_simcall_t simcall, smx_process_t self){
541 return SIMIX_process_self_get_data(self);
544 void* SIMIX_process_self_get_data(smx_process_t self)
546 xbt_assert(self == SIMIX_process_self(), "This is not the current process");
551 return SIMIX_process_get_data(self);
554 void SIMIX_pre_process_set_data(smx_simcall_t simcall, smx_process_t process,
556 SIMIX_process_set_data(process, data);
558 void SIMIX_process_self_set_data(smx_process_t self, void *data)
560 xbt_assert(self == SIMIX_process_self(), "This is not the current process");
562 SIMIX_process_set_data(self, data);
565 void* SIMIX_pre_process_get_data(smx_simcall_t simcall, smx_process_t process){
566 return SIMIX_process_get_data(process);
568 void* SIMIX_process_get_data(smx_process_t process)
570 return process->data;
573 void SIMIX_process_set_data(smx_process_t process, void *data)
575 process->data = data;
578 smx_host_t SIMIX_pre_process_get_host(smx_simcall_t simcall, smx_process_t process){
579 return SIMIX_process_get_host(process);
581 smx_host_t SIMIX_process_get_host(smx_process_t process)
583 return process->smx_host;
586 /* needs to be public and without simcall because it is called
587 by exceptions and logging events */
588 const char* SIMIX_process_self_get_name(void) {
590 smx_process_t process = SIMIX_process_self();
591 if (process == NULL || process == simix_global->maestro_process)
594 return SIMIX_process_get_name(process);
597 const char* SIMIX_pre_process_get_name(smx_simcall_t simcall, smx_process_t process) {
598 return SIMIX_process_get_name(process);
600 const char* SIMIX_process_get_name(smx_process_t process)
602 return process->name;
605 smx_process_t SIMIX_process_get_by_name(const char* name)
609 xbt_swag_foreach(proc, simix_global->process_list)
611 if(!strcmp(name, proc->name))
617 int SIMIX_pre_process_is_suspended(smx_simcall_t simcall, smx_process_t process){
618 return SIMIX_process_is_suspended(process);
620 int SIMIX_process_is_suspended(smx_process_t process)
622 return process->suspended;
625 xbt_dict_t SIMIX_pre_process_get_properties(smx_simcall_t simcall, smx_process_t process){
626 return SIMIX_process_get_properties(process);
628 xbt_dict_t SIMIX_process_get_properties(smx_process_t process)
630 return process->properties;
633 void SIMIX_pre_process_sleep(smx_simcall_t simcall, double duration)
635 if (MC_is_active()) {
636 MC_process_clock_add(simcall->issuer, duration);
637 simcall_process_sleep__set__result(simcall, SIMIX_DONE);
638 SIMIX_simcall_answer(simcall);
641 smx_action_t action = SIMIX_process_sleep(simcall->issuer, duration);
642 xbt_fifo_push(action->simcalls, simcall);
643 simcall->issuer->waiting_action = action;
646 smx_action_t SIMIX_process_sleep(smx_process_t process, double duration)
649 smx_host_t host = process->smx_host;
651 /* check if the host is active */
652 if (surf_workstation_model->extension.
653 workstation.get_state(host->host) != SURF_RESOURCE_ON) {
654 THROWF(host_error, 0, "Host %s failed, you cannot call this function",
658 action = xbt_mallocator_get(simix_global->action_mallocator);
659 action->type = SIMIX_ACTION_SLEEP;
662 action->category = NULL;
665 action->sleep.host = host;
666 action->sleep.surf_sleep =
667 surf_workstation_model->extension.workstation.sleep(host->host, duration);
669 surf_workstation_model->action_data_set(action->sleep.surf_sleep, action);
670 XBT_DEBUG("Create sleep action %p", action);
675 void SIMIX_post_process_sleep(smx_action_t action)
677 smx_simcall_t simcall;
680 while ((simcall = xbt_fifo_shift(action->simcalls))) {
682 switch(surf_workstation_model->action_state_get(action->sleep.surf_sleep)){
683 case SURF_ACTION_FAILED:
684 simcall->issuer->context->iwannadie = 1;
685 //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
688 case SURF_ACTION_DONE:
696 if (surf_workstation_model->extension.
697 workstation.get_state(simcall->issuer->smx_host->host) != SURF_RESOURCE_ON) {
698 simcall->issuer->context->iwannadie = 1;
700 simcall_process_sleep__set__result(simcall, state);
701 simcall->issuer->waiting_action = NULL;
702 SIMIX_simcall_answer(simcall);
705 SIMIX_process_sleep_destroy(action);
708 void SIMIX_process_sleep_destroy(smx_action_t action)
710 XBT_DEBUG("Destroy action %p", action);
711 if (action->sleep.surf_sleep)
712 action->sleep.surf_sleep->model_type->action_unref(action->sleep.surf_sleep);
713 xbt_mallocator_release(simix_global->action_mallocator, action);
716 void SIMIX_process_sleep_suspend(smx_action_t action)
718 surf_workstation_model->suspend(action->sleep.surf_sleep);
721 void SIMIX_process_sleep_resume(smx_action_t action)
723 surf_workstation_model->resume(action->sleep.surf_sleep);
727 * \brief Calling this function makes the process to yield.
729 * Only the current process can call this function, giving back the control to
732 * \param self the current process
734 void SIMIX_process_yield(smx_process_t self)
736 XBT_DEBUG("Yield process '%s'", self->name);
738 /* Go into sleep and return control to maestro */
739 SIMIX_context_suspend(self->context);
741 /* Ok, maestro returned control to us */
742 XBT_DEBUG("Control returned to me: '%s'", self->name);
744 if (self->new_host) {
745 SIMIX_process_change_host(self, self->new_host);
746 self->new_host = NULL;
749 if (self->context->iwannadie){
750 XBT_DEBUG("I wanna die!");
751 SIMIX_process_stop(self);
754 if(self->suspended) {
755 xbt_assert(!self->doexception, "Gloups! This exception may be lost by subsequent calls.");
757 SIMIX_process_suspend(self,self);
760 if (self->doexception) {
761 XBT_DEBUG("Wait, maestro left me an exception");
762 self->doexception = 0;
768 /* callback: context fetching */
769 xbt_running_ctx_t *SIMIX_process_get_running_context(void)
771 return SIMIX_process_self()->running_ctx;
774 /* callback: termination */
775 void SIMIX_process_exception_terminate(xbt_ex_t * e)
781 smx_context_t SIMIX_process_get_context(smx_process_t p) {
785 void SIMIX_process_set_context(smx_process_t p,smx_context_t c) {
790 * \brief Returns the list of processes to run.
792 xbt_dynar_t SIMIX_process_get_runnable(void)
794 return simix_global->process_to_run;
798 * \brief Returns the process from PID.
800 smx_process_t SIMIX_process_from_PID(int PID)
803 xbt_swag_foreach(proc, simix_global->process_list)
811 /** @brief returns a dynar containg all currently existing processes */
812 xbt_dynar_t SIMIX_processes_as_dynar(void) {
814 xbt_dynar_t res = xbt_dynar_new(sizeof(smx_process_t),NULL);
815 xbt_swag_foreach(proc, simix_global->process_list) {
816 xbt_dynar_push(res,&proc);
822 void SIMIX_process_on_exit_runall(smx_process_t process) {
823 s_smx_process_exit_fun_t exit_fun;
825 while (!xbt_dynar_is_empty(process->on_exit)) {
826 exit_fun = xbt_dynar_pop_as(process->on_exit,s_smx_process_exit_fun_t);
827 (exit_fun.fun)(exit_fun.arg);
831 void SIMIX_pre_process_on_exit(smx_simcall_t simcall, smx_process_t process,
832 int_f_pvoid_t fun, void *data) {
833 SIMIX_process_on_exit(process, fun, data);
836 void SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data) {
837 xbt_assert(process, "current process not found: are you in maestro context ?");
839 if (!process->on_exit) {
840 process->on_exit = xbt_dynar_new(sizeof(s_smx_process_exit_fun_t), NULL);
843 s_smx_process_exit_fun_t exit_fun = {fun, data};
845 xbt_dynar_push_as(process->on_exit,s_smx_process_exit_fun_t,exit_fun);
848 void SIMIX_pre_process_auto_restart_set(smx_simcall_t simcall, smx_process_t process,
850 SIMIX_process_auto_restart_set(process, auto_restart);
853 * \brief Sets the auto-restart status of the process.
854 * If set to 1, the process will be automatically restarted when its host
857 void SIMIX_process_auto_restart_set(smx_process_t process, int auto_restart) {
858 process->auto_restart = auto_restart;
861 smx_process_t SIMIX_pre_process_restart(smx_simcall_t simcall, smx_process_t process) {
862 return SIMIX_process_restart(process, simcall->issuer);
865 * \brief Restart a process.
866 * Restart a process, starting it again from the beginning.
868 smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) {
869 XBT_DEBUG("Restarting process %s on %s", process->name, process->smx_host->name);
870 //retrieve the arguments of the old process
871 //FIXME: Factorise this with SIMIX_host_add_auto_restart_process ?
872 s_smx_process_arg_t arg;
873 arg.code = process->code;
874 arg.hostname = process->smx_host->name;
875 arg.kill_time = process->kill_time;
876 arg.argc = process->argc;
877 arg.data = process->data;
879 arg.argv = xbt_new(char*,process->argc + 1);
880 for (i = 0; i < arg.argc; i++) {
881 arg.argv[i] = xbt_strdup(process->argv[i]);
883 arg.argv[process->argc] = NULL;
884 arg.properties = NULL;
885 arg.auto_restart = process->auto_restart;
886 //kill the old process
887 SIMIX_process_kill(process,issuer);
888 //start the new process
889 smx_process_t new_process;
890 if (simix_global->create_process_function) {
891 simix_global->create_process_function(&new_process,
903 simcall_process_create(&new_process,