/** The guy we will move from host to host. It move alone and then is moved by policeman back */ static int emigrant(int argc, char *argv[]) { msg_task_t task; XBT_INFO ("I'll look for a new job on another machine where the grass is greener."); MSG_process_migrate(MSG_process_self(), MSG_get_host_by_name("Boivin")); XBT_INFO("Yeah, found something to do"); task = MSG_task_create("job", 98095000, 0, NULL); MSG_task_execute(task); MSG_task_destroy(task); MSG_process_sleep(2); XBT_INFO("Moving back home after work"); MSG_process_migrate(MSG_process_self(), MSG_get_host_by_name("Jacquelin")); MSG_process_migrate(MSG_process_self(), MSG_get_host_by_name("Boivin")); MSG_process_sleep(4); xbt_mutex_acquire(mutex); process_to_migrate = MSG_process_self(); xbt_cond_broadcast(cond); xbt_mutex_release(mutex); MSG_process_suspend(MSG_process_self()); msg_host_t h = MSG_process_get_host(MSG_process_self()); XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h)); XBT_INFO("Uh, nothing to do here. Stopping now"); return 0; } /* end_of_emigrant */
static int xbt_thread_create_wrapper(int argc, char *argv[]) { smx_process_t self = SIMIX_process_self(); xbt_thread_t t = (xbt_thread_t) SIMIX_process_self_get_data(self); simcall_process_set_data(self, t->father_data); t->code(t->userparam); if (t->joinable) { t->done = 1; xbt_mutex_acquire(t->mutex); xbt_cond_broadcast(t->cond); xbt_mutex_release(t->mutex); } else { xbt_mutex_destroy(t->mutex); xbt_cond_destroy(t->cond); free(t->name); free(t); } return 0; }