当前位置: 首页>>代码示例>>C++>>正文


C++ xbt_dynar_push函数代码示例

本文整理汇总了C++中xbt_dynar_push函数的典型用法代码示例。如果您正苦于以下问题:C++ xbt_dynar_push函数的具体用法?C++ xbt_dynar_push怎么用?C++ xbt_dynar_push使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xbt_dynar_push函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: surf_new_model_init_default

void surf_new_model_init_default(void)
{
    surf_new_model_init_internal();
    new_model_define_callbacks();

    xbt_dynar_push(model_list, &surf_new_model);
}
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:7,代码来源:new_model.c

示例2: STag_surfxml_include

void STag_surfxml_include(void)
{
  XBT_DEBUG("STag_surfxml_include '%s'",A_surfxml_include_file);
  xbt_dynar_push(surf_parsed_filename_stack,&surf_parsed_filename); // save old file name
  surf_parsed_filename = xbt_strdup(A_surfxml_include_file);

  xbt_dynar_push(surf_file_to_parse_stack, &surf_file_to_parse); //save old file descriptor

  surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r"); // read new file descriptor
  xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n",
              A_surfxml_include_file);
  xbt_dynar_push(surf_input_buffer_stack,&surf_input_buffer);
  surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
  surf_parse_push_buffer_state(surf_input_buffer);

  fflush(NULL);
}
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:17,代码来源:surfxml_parse.c

示例3: coordinator

static int coordinator(int argc, char *argv[])
{
  int CS_used = 0;   
  msg_task_t task = NULL, answer = NULL; 
  xbt_dynar_t requests = xbt_dynar_new(sizeof(char *), NULL);
  char *req;

  while(1){  
    MSG_task_receive(&task, "coordinator");
    const char *kind = MSG_task_get_name(task); 
    if (!strcmp(kind, "request")) {    
      req = MSG_task_get_data(task);
      if (CS_used) {           
        XBT_INFO("CS already used. Queue the request.");
        xbt_dynar_push(requests, &req);
      } else {               
        if(strcmp(req, "1") != 0){
          XBT_INFO("CS idle. Grant immediatly");
          answer = MSG_task_create("grant", 0, 1000, NULL);
          MSG_task_send(answer, req);
          CS_used = 1;
          answer = NULL;
        }
      }
    } else {
      if (!xbt_dynar_is_empty(requests)) {
        XBT_INFO("CS release. Grant to queued requests (queue size: %lu)", xbt_dynar_length(requests));
        xbt_dynar_shift(requests, &req);
        if(strcmp(req, "1") != 0){
          MSG_task_send(MSG_task_create("grant", 0, 1000, NULL), req);
        }else{
          xbt_dynar_push(requests, &req);
          CS_used = 0;
        }
      }else{
        XBT_INFO("CS release. resource now idle");
        CS_used = 0;
      }
    }
    MSG_task_destroy(task);
    task = NULL;
    kind = NULL;
    req = NULL;
  }
  return 0;
}
开发者ID:glesserd,项目名称:simgrid,代码行数:46,代码来源:bugged1_liveness.c

示例4: SD_task_get_ready_children

/* Build the set of the compute successors of a task that are ready (i.e., with all parents already scheduled). Both
 * data and control dependencies are checked. As more than one transfer may exist between two compute tasks, it is
 * mandatory to check whether the successor is not already in the set.
 */
xbt_dynar_t SD_task_get_ready_children(SD_task_t t){
  unsigned int i;
  xbt_dynar_t children=NULL, ready_children;
  xbt_dynar_t output_transfers = SD_task_get_children(t);
  SD_task_t output, child;

  ready_children = xbt_dynar_new(sizeof(SD_task_t), NULL);

  xbt_dynar_foreach(output_transfers, i, output){
    if (SD_task_get_kind(output) == SD_TASK_COMM_E2E) {
      /* Data dependency case: a compute task is followed by a data transfer. Its child (in a scheduling sense) is
       * then the grand child
       */
      children = SD_task_get_children(output);
      xbt_dynar_get_cpy(children, 0, &child);

      /* check if this child is already in the set */
      if (xbt_dynar_member(ready_children, &child)){
        XBT_DEBUG("%s already seen, ignore", SD_task_get_name(child));
        xbt_dynar_free_container(&children); /* avoid memory leaks */
        continue;
      }

      if (SD_task_get_kind(child) == SD_TASK_COMP_SEQ && (SD_task_get_state(child) == SD_NOT_SCHEDULED ||
           SD_task_get_state(child) == SD_SCHEDULABLE) && SD_task_is_ready(child)){
        xbt_dynar_push(ready_children, &child);
      }
      xbt_dynar_free_container(&children); /* avoid memory leaks */
    } else {
      /* Control dependency case: a compute task successor is another compute task. */
      /* check if this child is already in the set */
      if (xbt_dynar_member(ready_children, &output)){
        XBT_DEBUG("%s already seen, ignore", SD_task_get_name(output));
        continue;
      }
      if (SD_task_get_kind(output) == SD_TASK_COMP_SEQ && (SD_task_get_state(output) == SD_NOT_SCHEDULED ||
           SD_task_get_state(output) == SD_SCHEDULABLE)&& SD_task_is_ready(output)){
        xbt_dynar_push(ready_children, &output);
      }
    }
  }

  xbt_dynar_free_container(&output_transfers); /* avoid memory leaks */

  return ready_children;
}
开发者ID:frs69wq,项目名称:EnsembleSched,代码行数:50,代码来源:task.c

示例5: surf_host_model_init_compound

void surf_host_model_init_compound()
{
  xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
  xbt_assert(surf_network_model, "No network model defined yet!");

  surf_host_model = new simgrid::surf::HostCLM03Model();
  xbt_dynar_push(all_existing_models, &surf_host_model);
}
开发者ID:adegomme,项目名称:simgrid,代码行数:8,代码来源:host_clm03.cpp

示例6: surf_network_model_init_Constant

/*********
 * Model *
 *********/
void surf_network_model_init_Constant()
{
  xbt_assert(surf_network_model == nullptr);
  surf_network_model = new simgrid::surf::NetworkConstantModel();
  xbt_dynar_push(all_existing_models, &surf_network_model);

  routing_model_create(nullptr);
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:11,代码来源:network_constant.cpp

示例7: surfxml_bufferstack_push

void surfxml_bufferstack_push(int new_one)
{
  if (!new_one)
    old_buff = surfxml_bufferstack;
  else {
    xbt_dynar_push(surfxml_bufferstack_stack, &surfxml_bufferstack);
    surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size);
  }
}
开发者ID:R7R8,项目名称:simgrid,代码行数:9,代码来源:surfxml_parseplatf.cpp

示例8: surf_host_model_init_current_default

void surf_host_model_init_current_default(void)
{
  surf_host_model = new simgrid::surf::HostCLM03Model();
  xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", "yes");
  surf_cpu_model_init_Cas01();
  surf_network_model_init_LegrandVelho();

  xbt_dynar_push(all_existing_models, &surf_host_model);
}
开发者ID:adegomme,项目名称:simgrid,代码行数:9,代码来源:host_clm03.cpp

示例9: master_fun

int master_fun(int argc, char *argv[])
{
  msg_vm_t vm;
  unsigned int i;

  xbt_dynar_t worker_pms = MSG_process_get_data(MSG_process_self());
  int nb_workers = xbt_dynar_length(worker_pms);

  xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL);


  /* Launch VMs and worker processes. One VM per PM, and one worker process per VM. */

  XBT_INFO("# Launch %d VMs", nb_workers);
  for (i = 0; i< nb_workers; i++) {
    char *vm_name = bprintf("VM%02d", i);
    char *pr_name = bprintf("WRK%02d", i);

    msg_host_t pm = xbt_dynar_get_as(worker_pms, i, msg_host_t);

    XBT_INFO("create %s on PM(%s)", vm_name, MSG_host_get_name(pm));
    msg_vm_t vm = MSG_vm_create_core(pm, vm_name);

    s_vm_params_t params;
    memset(&params, 0, sizeof(params));
    params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes
    MSG_host_set_params(vm, &params);

    MSG_vm_start(vm);
    xbt_dynar_push(vms, &vm);

    XBT_INFO("put a process (%s) on %s", pr_name, vm_name);
    MSG_process_create(pr_name, worker_fun, NULL, vm);

    xbt_free(vm_name);
    xbt_free(pr_name);
  }


  /* Send a bunch of work to every one */
  XBT_INFO("# Send a task to %d worker process", nb_workers);
  send_tasks(nb_workers);

  XBT_INFO("# Suspend all VMs");
  xbt_dynar_foreach(vms, i, vm) {
    const char *vm_name = MSG_host_get_name(vm);
    XBT_INFO("suspend %s", vm_name);
    MSG_vm_suspend(vm);
  }

  XBT_INFO("# Wait a while");
  MSG_process_sleep(2);

  XBT_INFO("# Resume all VMs");
  xbt_dynar_foreach(vms, i, vm) {
    MSG_vm_resume(vm);
  }
开发者ID:apargupta,项目名称:simgrid,代码行数:57,代码来源:master_worker_vm.c

示例10: surf_network_model_init_Constant

/*********
 * Model *
 *********/
void surf_network_model_init_Constant()
{
  xbt_assert(surf_network_model == NULL);
  surf_network_model = new NetworkConstantModel();

  sg_platf_host_add_cb(netcste_count_hosts);

  ModelPtr model = surf_network_model;
  xbt_dynar_push(model_list, &model);
}
开发者ID:FlorianPO,项目名称:simgrid,代码行数:13,代码来源:network_constant.cpp

示例11: tmgr_trace_new_from_string

tmgr_trace_t tmgr_trace_new_from_string(const char *name, const char *input, double periodicity)
{
  int linecount = 0;
  tmgr_event_t last_event = nullptr;
  unsigned int cpt;
  char *val;

  xbt_assert(trace_list.find(name) == trace_list.end(), "Refusing to define trace %s twice", name);
  xbt_assert(periodicity >= 0, "Invalid periodicity %g (must be positive)", periodicity);

  tmgr_trace_t trace = new simgrid::trace_mgr::trace();

  xbt_dynar_t list = xbt_str_split(input, "\n\r");
  xbt_dynar_foreach(list, cpt, val) {
    s_tmgr_event_t event;
    linecount++;
    xbt_str_trim(val, " \t\n\r\x0B");
    if (val[0] == '#' || val[0] == '\0' || val[0] == '%') // pass comments
      continue;

    if (sscanf(val, "PERIODICITY " "%lg" "\n", &periodicity) == 1)
      continue;

    xbt_assert(sscanf(val, "%lg" " " "%lg" "\n", &event.delta, &event.value) == 2,
        "%s:%d: Syntax error in trace\n%s", name, linecount, input);

    if (last_event) {
      xbt_assert(last_event->delta <= event.delta,
          "%s:%d: Invalid trace: Events must be sorted, but time %g > time %g.\n%s",
          name, linecount, last_event->delta, event.delta, input);

      last_event->delta = event.delta - last_event->delta;
    } else {
      if(event.delta > 0.0){
        s_tmgr_event_t first_event;
        first_event.delta=event.delta;
        first_event.value=-1.0;
        xbt_dynar_push(trace->event_list, &first_event);
      }
    }
    xbt_dynar_push(trace->event_list, &event);
    last_event = (tmgr_event_t)xbt_dynar_get_ptr(trace->event_list, xbt_dynar_length(trace->event_list) - 1);
  }
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:43,代码来源:trace_mgr.cpp

示例12: syscall_dup_post

/** @brief handles dup at the exit
    Update the table of file descriptors, and also the pipe objects if needed */
void syscall_dup_post(reg_s * reg, process_descriptor_t * proc)
{
  proc_outside(proc);
  unsigned int oldfd = (int) reg->arg[0];
  unsigned int newfd = (int) reg->ret;

  fd_descriptor_t *file_desc = process_descriptor_get_fd(proc, oldfd);
  file_desc->refcount++;
  process_descriptor_set_fd(proc, newfd, file_desc);

  if (strace_option)
    fprintf(stderr, "[%d] dup(%d, %d) = %d \n", proc->pid, oldfd, newfd, (int) reg->ret);

  if (file_desc->type == FD_PIPE) {
    pipe_t *pipe = file_desc->pipe;

    // look for the fd in the read end of the pipe
    xbt_dynar_t read_end = pipe->read_end;
    unsigned int cpt_in;
    pipe_end_t end_in;
    xbt_dynar_foreach(read_end, cpt_in, end_in) {
      if (end_in->fd == oldfd && end_in->proc == proc) {
        pipe_end_t dup_end = xbt_malloc0(sizeof(pipe_end_s));
        dup_end->fd = newfd;
        dup_end->proc = end_in->proc;
        xbt_dynar_push(read_end, &dup_end);
      }
    }

    // look for the fd in the write end of the pipe
    xbt_dynar_t write_end = pipe->write_end;
    unsigned int cpt_out;
    pipe_end_t end_out;
    xbt_dynar_foreach(write_end, cpt_out, end_out) {
      if (end_out->fd == oldfd && end_out->proc == proc) {
        pipe_end_t dup_end = xbt_malloc0(sizeof(pipe_end_s));
        dup_end->fd = newfd;
        dup_end->proc = end_out->proc;
        xbt_dynar_push(write_end, &dup_end);
      }
    }
  }
开发者ID:mquinson,项目名称:simterpose,代码行数:44,代码来源:sys_dup.c

示例13: xbt_str_split_str

/**
 * \brief This functions splits a string after using another string as separator
 * For example A!!B!!C splitted after !! will return the dynar {A,B,C}
 * \return An array of dynars containing the string tokens
 */
xbt_dynar_t xbt_str_split_str(const char *s, const char *sep)
{
  xbt_dynar_t res = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
  int done;
  const char *p, *q;

  p = q = s;
  done = 0;

  if (s[0] == '\0')
    return res;
  if (sep[0] == '\0') {
    s = xbt_strdup(s);
    xbt_dynar_push(res, &s);
    return res;
  }

  while (!done) {
    char *to_push;
    int v = 0;
    //get the start of the first occurence of the substring
    q = strstr(p, sep);
    //if substring was not found add the entire string
    if (NULL == q) {
      v = strlen(p);
      to_push = xbt_malloc(v + 1);
      memcpy(to_push, p, v);
      to_push[v] = '\0';
      xbt_dynar_push(res, &to_push);
      done = 1;
    } else {
      //get the appearance
      to_push = xbt_malloc(q - p + 1);
      memcpy(to_push, p, q - p);
      //add string terminator
      to_push[q - p] = '\0';
      xbt_dynar_push(res, &to_push);
      p = q + strlen(sep);
    }
  }
  return res;
}
开发者ID:FlorianPO,项目名称:simgrid,代码行数:47,代码来源:xbt_str.c

示例14: jed_event_add_resources

void jed_event_add_resources(jed_event_t event, xbt_dynar_t host_selection) {
  xbt_dynar_t resource_subset_list;
  jed_res_subset_t res_set;
  unsigned int i;

  resource_subset_list = xbt_dynar_new(sizeof(jed_res_subset_t), NULL);

  jed_simgrid_get_resource_selection_by_hosts(resource_subset_list, host_selection);
  xbt_dynar_foreach(resource_subset_list, i, res_set)  {
    xbt_dynar_push(event->resource_subsets, &res_set);
  }
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:11,代码来源:jedule_events.cpp

示例15: MSG_comm_testany

/** \ingroup msg_task_usage
 * \brief This function checks if a communication is finished.
 * \param comms a vector of communications
 * \return the position of the finished communication if any
 * (but it may have failed, use MSG_comm_get_status() to know its status),
 * or -1 if none is finished
 */
int MSG_comm_testany(xbt_dynar_t comms)
{
  xbt_ex_t e;
  int finished_index = -1;

  /* create the equivalent dynar with SIMIX objects */
  xbt_dynar_t s_comms = xbt_dynar_new(sizeof(smx_synchro_t), NULL);
  msg_comm_t comm;
  unsigned int cursor;
  xbt_dynar_foreach(comms, cursor, comm) {
    xbt_dynar_push(s_comms, &comm->s_comm);
  }
开发者ID:tempbottle,项目名称:simgrid,代码行数:19,代码来源:msg_gos.c


注:本文中的xbt_dynar_push函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。