Exemplo n.º 1
0
static int master(int argc, char *argv[])
{
  msg_task_t task = NULL;

  // I am the master of emigrant process,
  // I tell it where it must emigrate to.
  xbt_dynar_t destinations = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Tremblay"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Jupiter"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Fafard"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Ginette"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Bourassa"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Fafard"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Tremblay"));
  xbt_dynar_push_as (destinations, char*, xbt_strdup ("Ginette"));
  xbt_dynar_push_as (destinations, char*, NULL);

  char *destination;
  unsigned int i;
  xbt_dynar_foreach(destinations, i, destination){
    task = MSG_task_create("task", 0, 0, NULL);
    if (destination){
      MSG_task_set_data(task, xbt_strdup (destination));
    }
    MSG_task_set_category(task, "migration_order");
    MSG_task_send (task, "master_mailbox");
    task = NULL;
  }
Exemplo n.º 2
0
      /** @brief helper function to send task */
      int process_send_call(reg_s * reg, process_descriptor_t * proc, process_descriptor_t * remote_proc, void * data)
      {
      XBT_DEBUG("Entering process_send_call");
      if (socket_registered(proc, (int) reg->arg[0]) != -1) { 
      if (!socket_netlink(proc, (int) reg->arg[0])) {
      XBT_DEBUG("%d This is not a netlink socket", (int) reg->arg[0]);
      //   compute_computation_time(proc);   // cree la computation task
      struct infos_socket *is = get_infos_socket(proc, (int) reg->arg[0]);
      struct infos_socket *s = comm_get_peer(is);
      is->ref_nb++;
      s->ref_nb++;

      XBT_DEBUG("%d->%d", (int) reg->arg[0], (int) reg->ret);
      XBT_DEBUG("Sending data(%d) on socket %d", (int) reg->ret, s->fd.fd);
      handle_new_send(reg, is, data);

      msg_task_t task = create_send_communication_task(proc, is, (int) reg->ret, proc->host, s->fd.proc->host);
      XBT_DEBUG("hosts: %s send to %s (size: %d)", MSG_host_get_name(proc->host), MSG_host_get_name(s->fd.proc->host),
	(int) reg->ret);


      MSG_task_set_bytes_amount(task, (int) reg->ret);
      MSG_task_set_data(task, data);

      send_task(s->fd.proc->host, task);

      is->ref_nb--;
      s->ref_nb--;
      return 1;
    }
      return 0;
    } else
	xbt_die("The socket is not registered");
      return 0;
    }
Exemplo n.º 3
0
void jcomm_bind_task(JNIEnv *env, jobject jcomm) {
  msg_comm_t comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
  //test if we are receiving or sending a task.
  jboolean jreceiving = env->GetBooleanField(jcomm, jcomm_field_Comm_receiving);
  if (jreceiving == JNI_TRUE) {
    //bind the task object.
    msg_task_t task = MSG_comm_get_task(comm);
    xbt_assert(task != nullptr, "Task is nullptr");
    jobject jtask_global = static_cast<jobject>(MSG_task_get_data(task));
    //case where the data has already been retrieved
    if (jtask_global == nullptr) {
      return;
    }

    //Make sure the data will be correctly gc.
    jobject jtask_local = env->NewLocalRef(jtask_global);
    env->DeleteGlobalRef(jtask_global);

    env->SetObjectField(jcomm, jtask_field_Comm_task, jtask_local);

    MSG_task_set_data(task, nullptr);
  }
}