- smx_process_arg_t arg = *(smx_process_arg_t*)data;
- for (int i = 0; i < arg->argc; i++)
- xbt_free(arg->argv[i]);
- xbt_free(arg->argv);
- xbt_free(arg->name);
- delete arg;
-}
-/**
- * \brief Add a process to the list of the processes that the host will restart when it comes back
- * This function add a process to the list of the processes that will be restarted when the host comes
- * back. It is expected that this function is called when the host is down.
- * The processes will only be restarted once, meaning that you will have to register the process
- * again to restart the process again.
- */
-void SIMIX_host_add_auto_restart_process(sg_host_t host,
- const char *name,
- xbt_main_func_t code,
- void *data,
- const char *hostname,
- double kill_time,
- int argc, char **argv,
- xbt_dict_t properties,
- int auto_restart)
-{
- if (!sg_host_simix(host)->auto_restart_processes) {
- sg_host_simix(host)->auto_restart_processes = xbt_dynar_new(sizeof(smx_process_arg_t),_SIMIX_host_free_process_arg);
- }
- smx_process_arg_t arg = new s_smx_process_arg_t();
- arg->name = xbt_strdup(name);
- arg->code = code;
- arg->data = data;
- arg->hostname = hostname;
- arg->kill_time = kill_time;
- arg->argc = argc;
-
- arg->argv = xbt_new(char*,argc + 1);
-
- for (int i = 0; i < argc; i++)
- arg->argv[i] = xbt_strdup(argv[i]);
- arg->argv[argc] = NULL;
-
- arg->properties = properties;
- arg->auto_restart = auto_restart;
-
- if( host->isOff() && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_get_name(host))){
- xbt_dict_set(watched_hosts_lib,sg_host_get_name(host),host,NULL);
- XBT_DEBUG("Push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_get_name(host));
- }
- xbt_dynar_push_as(sg_host_simix(host)->auto_restart_processes,smx_process_arg_t,arg);
-}
-/**
- * \brief Restart the list of processes that have been registered to the host
- */
-void SIMIX_host_autorestart(sg_host_t host)
-{
- unsigned int cpt;
- smx_process_arg_t arg;
- xbt_dynar_t process_list = sg_host_simix(host)->auto_restart_processes;
- if (!process_list)
- return;
-
- xbt_dynar_foreach (process_list, cpt, arg) {
-
- XBT_DEBUG("Restarting Process %s(%s) right now", arg->argv[0], arg->hostname);
- if (simix_global->create_process_function) {
- simix_global->create_process_function(arg->argv[0],
- arg->code,
- NULL,
- arg->hostname,
- arg->kill_time,
- arg->argc,
- arg->argv,
- arg->properties,
- arg->auto_restart,
- NULL);
- } else {
- simcall_process_create(arg->argv[0],
- (xbt_main_func_t) arg->code,
- NULL,
- arg->hostname,
- arg->kill_time,
- arg->argc,
- arg->argv,
- arg->properties,
- arg->auto_restart);
-
- }
- /* arg->argv is used by the process created above. Hide it to
- * _SIMIX_host_free_process_arg() which is called by xbt_dynar_reset()
- * below. */
- arg->argc = 0;
- arg->argv = NULL;
- }
- xbt_dynar_reset(process_list);
-}
-
-smx_synchro_t simcall_HANDLER_execution_start(smx_simcall_t simcall,
- const char* name, double flops_amount, double priority, double bound, unsigned long affinity_mask) {
- return SIMIX_execution_start(simcall->issuer, name,flops_amount,priority,bound,affinity_mask);
-}
-smx_synchro_t SIMIX_execution_start(smx_process_t issuer, const char *name,
- double flops_amount, double priority, double bound, unsigned long affinity_mask){
-
- /* alloc structures and initialize */
- simgrid::simix::Exec *exec = new simgrid::simix::Exec();
- exec->name = xbt_strdup(name);
- exec->state = SIMIX_RUNNING;
- exec->host = issuer->host;
-