XBT_INFO("Sleep long enough for everyone to be done with previous batch of work");
MSG_process_sleep(1000-MSG_get_clock());
- XBT_INFO("Add one more process per VM, and dispatch a batch of work to everyone");
+ XBT_INFO("Add one more process per VM");
for (i=0;i<xbt_dynar_length(vms);i++) {
msg_vm_t vm = xbt_dynar_get_as(vms,i,msg_vm_t);
char slavename[64];
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_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++) {
char **argv; /* arguments table if any */
int argc; /* arguments number if any */
MSG_error_t last_errno; /* the last value returned by a MSG_function */
+
+ msg_vm_t vm; /* virtual machine the process is in */
+
void* data; /* user data */
} s_simdata_process_t, *simdata_process_t;
* @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) {
+ /* check if the process is already in a VM */
+ simdata_process_t simdata = simcall_process_get_data(process);
+ if (simdata->vm) {
+ msg_vm_t old_vm = simdata->vm;
+ int pos = xbt_dynar_search(old_vm->processes,&process);
+ xbt_dynar_remove_at(old_vm->processes,pos, NULL);
+ }
+ /* check if the host is in the right host */
+ if (simdata->m_host != vm->location) {
+ MSG_process_migrate(process,vm->location);
+ }
+ simdata->vm = vm;
+
xbt_dynar_push_as(vm->processes,m_process_t,process);
}
/** @brief Removes the given process from the given VM, and kill it
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);
}
}
unsigned int cpt;
m_process_t process;
xbt_dynar_foreach(vm->processes,cpt,process) {
- MSG_process_kill(process);
+ MSG_process_kill(process);
}
}