+ unsigned int cpt;
+ smx_process_arg_t arg;
+ xbt_dynar_t process_list = SIMIX_host_priv(host)->auto_restart_processes;
+ if (!process_list)
+ return;
+
+ xbt_dynar_foreach (process_list, cpt, arg) {
+
+ smx_process_t process;
+
+ XBT_DEBUG("Restarting Process %s(%s) right now", arg->argv[0], arg->hostname);
+ if (simix_global->create_process_function) {
+ simix_global->create_process_function(&process,
+ 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(&process,
+ arg->argv[0],
+ 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);
+}
+
+void SIMIX_host_autorestart(smx_host_t host)
+{
+ if(simix_global->autorestart)
+ simix_global->autorestart(host);
+ else
+ xbt_die("No function for simix_global->autorestart");
+}
+
+smx_synchro_t SIMIX_host_execute(const char *name,
+ smx_host_t host, double flops_amount, double priority, double bound, unsigned long affinity_mask){
+
+ /* alloc structures and initialize */
+ smx_synchro_t synchro = xbt_mallocator_get(simix_global->synchro_mallocator);
+ synchro->type = SIMIX_SYNC_EXECUTE;
+ synchro->name = xbt_strdup(name);
+ synchro->state = SIMIX_RUNNING;
+ synchro->execution.host = host;
+ synchro->category = NULL;
+
+ /* set surf's action */
+ if (!MC_is_active() && !MC_record_replay_is_active()) {
+
+ synchro->execution.surf_exec = surf_workstation_execute(host, flops_amount);
+ surf_action_set_data(synchro->execution.surf_exec, synchro);
+ surf_action_set_priority(synchro->execution.surf_exec, priority);
+
+ /* Note (hypervisor): for multicore, the bound value being passed to the
+ * surf layer should not be zero (i.e., unlimited). It should be the
+ * capacity of a CPU core. */
+ if (bound == 0)
+ surf_cpu_action_set_bound(synchro->execution.surf_exec, SIMIX_host_get_speed(host));
+ else
+ surf_cpu_action_set_bound(synchro->execution.surf_exec, bound);
+
+ if (affinity_mask != 0) {
+ /* just a double check to confirm that this host is the host where this task is running. */
+ xbt_assert(synchro->execution.host == host);
+ surf_cpu_action_set_affinity(synchro->execution.surf_exec, host, affinity_mask);
+ }
+ }
+
+ XBT_DEBUG("Create execute synchro %p: %s", synchro, synchro->name);
+
+ return synchro;
+}
+
+smx_synchro_t SIMIX_host_parallel_execute(const char *name,
+ int host_nb, smx_host_t *host_list,
+ double *flops_amount, double *bytes_amount,
+ double amount, double rate){
+
+ void **workstation_list = NULL;
+ int i;
+
+ /* alloc structures and initialize */
+ smx_synchro_t synchro = xbt_mallocator_get(simix_global->synchro_mallocator);
+ synchro->type = SIMIX_SYNC_PARALLEL_EXECUTE;
+ synchro->name = xbt_strdup(name);
+ synchro->state = SIMIX_RUNNING;
+ synchro->execution.host = NULL; /* FIXME: do we need the list of hosts? */
+ synchro->category = NULL;
+
+ /* set surf's synchro */
+ workstation_list = xbt_new0(void *, host_nb);
+ for (i = 0; i < host_nb; i++)
+ workstation_list[i] = surf_workstation_resource_priv(host_list[i]);
+
+
+ /* FIXME: what happens if host_list contains VMs and PMs. If
+ * execute_parallel_task() does not change the state of the model, we can mix
+ * them. */
+ surf_model_t ws_model = surf_resource_model(host_list[0], SURF_WKS_LEVEL);
+ for (i = 1; i < host_nb; i++) {
+ surf_model_t ws_model_tmp = surf_resource_model(host_list[i], SURF_WKS_LEVEL);
+ if (ws_model_tmp != ws_model) {
+ XBT_CRITICAL("mixing VMs and PMs is not supported");
+ DIE_IMPOSSIBLE;
+ }
+ }
+
+ /* set surf's synchro */
+ if (!MC_is_active() && !MC_record_replay_is_active()) {
+ synchro->execution.surf_exec =
+ surf_workstation_model_execute_parallel_task((surf_workstation_model_t)surf_workstation_model,
+ host_nb, workstation_list, flops_amount, bytes_amount, rate);
+
+ surf_action_set_data(synchro->execution.surf_exec, synchro);
+ }
+ XBT_DEBUG("Create parallel execute synchro %p", synchro);
+
+ return synchro;
+}
+
+void SIMIX_host_execution_destroy(smx_synchro_t synchro){
+ XBT_DEBUG("Destroy synchro %p", synchro);
+
+ if (synchro->execution.surf_exec) {
+ surf_action_unref(synchro->execution.surf_exec);
+ synchro->execution.surf_exec = NULL;
+ }
+ xbt_free(synchro->name);
+ xbt_mallocator_release(simix_global->synchro_mallocator, synchro);
+}
+
+void SIMIX_host_execution_cancel(smx_synchro_t synchro){
+ XBT_DEBUG("Cancel synchro %p", synchro);
+
+ if (synchro->execution.surf_exec)
+ surf_action_cancel(synchro->execution.surf_exec);
+}
+
+double SIMIX_host_execution_get_remains(smx_synchro_t synchro){
+ double result = 0.0;
+
+ if (synchro->state == SIMIX_RUNNING)
+ result = surf_action_get_remains(synchro->execution.surf_exec);
+
+ return result;
+}
+
+e_smx_state_t SIMIX_host_execution_get_state(smx_synchro_t synchro){
+ return synchro->state;
+}
+
+void SIMIX_host_execution_set_priority(smx_synchro_t synchro, double priority){
+
+ if(synchro->execution.surf_exec)
+ surf_action_set_priority(synchro->execution.surf_exec, priority);
+}
+
+void SIMIX_host_execution_set_bound(smx_synchro_t synchro, double bound){
+
+ if(synchro->execution.surf_exec)
+ surf_cpu_action_set_bound(synchro->execution.surf_exec, bound);
+}
+
+void SIMIX_host_execution_set_affinity(smx_synchro_t synchro, smx_host_t host, unsigned long mask){
+ xbt_assert(synchro->type == SIMIX_SYNC_EXECUTE);