/** The Dream master: */ static int dream_master(int argc, char *argv[]) { msg_process_t lazy = NULL; XBT_INFO("Let's create a lazy guy."); /** - Create a @ref lazy_guy process */ lazy = MSG_process_create("Lazy", lazy_guy, NULL, MSG_host_self()); XBT_INFO("Let's wait a little bit..."); SLEEP(10.0); /** - Wait for 10 seconds */ XBT_INFO("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!"); MSG_process_resume(lazy); /** - Then wake up the @ref lazy_guy */ SLEEP(5.0); /** Repeat two times: */ XBT_INFO("Suspend the lazy guy while he's sleeping..."); MSG_process_suspend(lazy); /** - Suspend the @ref lazy_guy while he's asleep */ XBT_INFO("Let him finish his siesta."); SLEEP(10.0); /** - Wait for 10 seconds */ XBT_INFO("Wake up, lazy guy!"); MSG_process_resume(lazy); /** - Then wake up the @ref lazy_guy again */ SLEEP(5.0); XBT_INFO("Suspend again the lazy guy while he's sleeping..."); MSG_process_suspend(lazy); XBT_INFO("This time, don't let him finish his siesta."); SLEEP(2.0); XBT_INFO("Wake up, lazy guy!"); MSG_process_resume(lazy); XBT_INFO("OK, goodbye now."); return 0; }
/* This function move the emigrant on Jacquelin */ static int policeman(int argc, char *argv[]) { xbt_mutex_acquire(mutex); XBT_INFO("Wait a bit before migrating the emigrant."); while (process_to_migrate == NULL) xbt_cond_wait(cond, mutex); MSG_process_migrate(process_to_migrate, MSG_get_host_by_name("Jacquelin")); XBT_INFO("I moved the emigrant"); MSG_process_resume(process_to_migrate); xbt_mutex_release(mutex); return 0; } /* end_of_policeman */
static int killer(int argc, char *argv[]) { XBT_INFO("Hello!"); /* - First start a victim process */ msg_process_t poor_victim = MSG_process_create("victim", victim, NULL, MSG_host_by_name("Fafard")); MSG_process_sleep(10.0); XBT_INFO("Resume process"); /* - Resume it from its suspended state */ MSG_process_resume(poor_victim); XBT_INFO("Kill process"); /* - and then kill it */ MSG_process_kill(poor_victim); XBT_INFO("OK, goodbye now."); return 0; }
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject jprocess) { msg_process_t process = jprocess_to_native_process(jprocess, env); if (!process) { jxbt_throw_notbound(env, "process", jprocess); return; } /* try to resume the process */ msg_error_t rv = MSG_process_resume(process); jxbt_check_res("MSG_process_resume()", rv, MSG_OK, bprintf("unexpected error , please report this bug")); }