Beispiel #1
0
/** 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 */
Beispiel #2
0
/** \ingroup msg_task_usage
 * \brief Executes a task and waits for its termination.
 *
 * This function is used for describing the behavior of a process. It
 * takes only one parameter.
 * \param task a #msg_task_t to execute on the location on which the process is running.
 * \return #MSG_OK if the task was successfully completed, #MSG_TASK_CANCELED
 * or #MSG_HOST_FAILURE otherwise
 */
msg_error_t MSG_task_execute(msg_task_t task)
{
  /* TODO: add this to other locations */
  msg_host_t host = MSG_process_get_host(MSG_process_self());
  MSG_host_add_task(host, task);

  msg_error_t ret = MSG_parallel_task_execute(task);

  MSG_host_del_task(host, task);

  return ret;
}
Beispiel #3
0
    xbt_dynar_foreach (process_list, cursor, process)
    {
	process_name = MSG_process_get_name (process);
	host = MSG_process_get_host (process);
	if ( strcmp (process_name, "worker") == 0 )
	{
	    config.workers[wid] = host;
	    /* Set the worker ID as its data. */
	    wi = xbt_new (struct w_info_s, 1);
	    wi->wid = wid;
	    MSG_host_set_data (host, (void*)wi);
	    /* Add the worker's cpu power to the grid total. */
	    config.grid_cpu_power += MSG_get_host_speed (host);
	    wid++;
	}
Beispiel #4
0
/** \ingroup m_host_management
 *
 * \brief Return the location on which the current process is executed.
 */
msg_host_t MSG_host_self(void)
{
  return MSG_process_get_host(NULL);
}
Beispiel #5
0
/** \ingroup m_host_management
 *
 * \brief Return the location on which the current process is executed.
 */
m_host_t MSG_host_self(void)
{
  return MSG_process_get_host(MSG_process_self());
}
Beispiel #6
0
void TRACE_msg_process_kill(msg_process_t process)
{
  if (TRACE_msg_process_is_enabled()){
    //kill means that this process no longer exists, let's destroy it
    TRACE_msg_process_destroy (MSG_process_get_name (process), MSG_process_get_PID (process), MSG_process_get_host (process));
  }
}