argv[2] = NULL;
MSG_vm_bind(vm, MSG_process_create_with_arguments(slavename,slave_fun,NULL,slaves[i],2,argv));
}
- work_batch(slaves_count*2);
XBT_INFO("Migrate everyone to the second host.");
for (i=0;i<xbt_dynar_length(vms);i++)
MSG_vm_migrate(vm,slaves[2]);
MSG_vm_resume(vm);
}
-
-
+ work_batch(slaves_count*2);
XBT_INFO("Let's shut down the simulation. 10 first processes will be shut down cleanly while the second half will forcefully get killed");
for (i = 0; i < slaves_count; i++) {
double kill_time;
} s_process_arg_t, *process_arg_t;
+
typedef struct msg_comm {
smx_action_t s_comm; /* SIMIX communication object encapsulated (the same for both processes) */
m_task_t task_sent; /* task sent (NULL for the receiver) */
int coreAmount;
} s_msg_vm_t;
+typedef struct s_msg_process_data {
+ void *data;
+ msg_vm_t current_vm;
+} s_msg_process_data_t, *msg_process_data_t;
+
/************************** Global variables ********************************/
typedef struct MSG_Global {
xbt_fifo_t host;
// get the MSG process from the SIMIX process
if (smx_proc == SIMIX_process_self()) {
- /* avoid a SIMIX request if this function is called by the process itself */
+ /* avoid a SIMIX request if this function is called by the process itself */
msg_proc = SIMIX_process_self_get_data(smx_proc);
+
SIMIX_process_self_set_data(smx_proc, NULL);
}
else {
msg_proc = simcall_process_get_data(smx_proc);
simcall_process_set_data(smx_proc, NULL);
}
-
#ifdef HAVE_TRACING
TRACE_msg_process_end(smx_proc);
#endif
- // free the data if a function was provided
- if (msg_proc->data && msg_global->process_data_cleanup) {
- msg_global->process_data_cleanup(msg_proc->data);
+ msg_process_data_t process_data = (msg_process_data_t)msg_proc->data;
+ //free the process data
+ if (process_data) {
+ //Remove the process from its vm
+ if (process_data->current_vm) {
+ int pos = xbt_dynar_search(process_data->current_vm->processes,&smx_proc);
+ xbt_dynar_remove_at(process_data->current_vm->processes,pos, NULL);
+ }
+ //Free the data if a function was provided
+ if (process_data->data && msg_global->process_data_cleanup) {
+ msg_global->process_data_cleanup(process_data->data);
+ }
+ xbt_free(process_data);
}
- // free the MSG process
+ //free the MSG process
xbt_free(msg_proc);
}
/* get from SIMIX the MSG process data, and then the user data */
simdata_process_t simdata = simcall_process_get_data(process);
- return simdata->data;
+ if (!simdata->data) {
+ return NULL;
+ }
+ return ((msg_process_data_t)simdata->data)->data;
}
/** \ingroup m_process_management
xbt_assert(process != NULL, "Invalid parameter");
simdata_process_t simdata = simcall_process_get_data(process);
- simdata->data = data;
-
+ if (!simdata->data) {
+ simdata->data = xbt_new0(s_msg_process_data_t, 1);
+ }
+ ((msg_process_data_t)simdata->data)->data = data;
return MSG_OK;
}
* @bug for now, if a binded process terminates, every VM functions will segfault. Baaaad.
*/
void MSG_vm_bind(msg_vm_t vm, m_process_t process) {
- xbt_dynar_push_as(vm->processes,m_process_t,process);
+ simdata_process_t simdata = simcall_process_get_data(process);
+ if (!simdata->data) {
+ simdata->data = xbt_new0(s_msg_process_data_t,1);
+ }
+ //If if it is already in a vm, get it out of it
+ if ( ((msg_process_data_t)(simdata->data))->current_vm) {
+ msg_vm_t old_vm = ((msg_process_data_t)(simdata->data))->current_vm;
+ int pos = xbt_dynar_search(old_vm->processes,&process);
+ xbt_dynar_remove_at(old_vm->processes,pos, NULL);
+ //If it is on the wrong host, migrate it to the new host
+ if (vm->location != old_vm->location) {
+ MSG_process_migrate(process,vm->location);
+ }
+ }
+
+ ((msg_process_data_t)(simdata->data))->current_vm = vm;
+
+ xbt_dynar_push_as(vm->processes,m_process_t,process);
}
/** @brief Removes the given process from the given VM, and kill it
* @ingroup msg_VMs
unsigned int cpt;
m_process_t process;
xbt_dynar_foreach(vm->processes,cpt,process) {
- XBT_INFO("suspend process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
+ XBT_DEBUG("suspend process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
MSG_process_suspend(process);
}
}
unsigned int cpt;
m_process_t process;
xbt_dynar_foreach(vm->processes,cpt,process) {
- XBT_INFO("resume process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
+ XBT_DEBUG("resume process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
MSG_process_resume(process);
}
}