Exemplo n.º 1
0
int Resource::seize(Arrival* arrival, int amount) {
  int status;
  // serve now
  if (room_in_server(amount, arrival->order.get_priority())) {
    if (arrival->is_monitored()) {
      arrival->set_start(this->name, sim->now());
      arrival->set_activity(this->name, sim->now());
    }
    insert_in_server(sim->verbose, sim->now(), arrival, amount);
    status = SUCCESS;
  }
  // enqueue
  else if (room_in_queue(amount, arrival->order.get_priority())) {
    if (arrival->is_monitored()) {
      arrival->set_start(this->name, sim->now());
      arrival->set_activity(this->name, 0);
    }
    insert_in_queue(sim->verbose, sim->now(), arrival, amount);
    status = ENQUEUED;
  }
  // reject
  else {
    if (sim->verbose) verbose_print(sim->now(), arrival->name, "REJECT");
    return REJECTED;
  }
  
  if (is_monitored()) observe(sim->now());
  return status;
}
Exemplo n.º 2
0
int Resource::post_release() {
  // serve another
  while (queue_count) 
    if (!try_serve_from_queue(sim->verbose, sim->now())) break;
    
  if (is_monitored()) observe(sim->now());
  return SUCCESS;
}
Exemplo n.º 3
0
int Resource::post_release() {
  // serve another
  while (queue_count)
    if (!try_serve_from_queue(sim->verbose, sim->now()))
      break;

  if (is_monitored())
    sim->record_resource(name, server_count, queue_count, capacity, queue_size);
  return SUCCESS;
}
Exemplo n.º 4
0
// ---------------------------------------------------------------------
//  hotNodes
// ---------------------------------------------------------------------
UINT32 hotNodes(cct_node_t* root, UINT32 threshold, 
                int (*is_monitored)(cct_node_t* node)) {
    UINT32 h=0;
    cct_node_t* child;
    for (child=root->first_child; child!=NULL; child=child->next_sibling)
        h += hotNodes(child,threshold,is_monitored);
    if (is_monitored(root)==1 && root->counter >= threshold) {
            //printf("hot = %lu  %p  %lu  %lu\n",h+1,root,root->counter,threshold);
            return h+1; 
    }
    else return h;
}
Exemplo n.º 5
0
void Resource::set_queue_size(int value) {
  if (queue_size == value)
    return;
  int last = queue_size;
  queue_size = value;
  if (last < 0 || (queue_size < last && queue_size >= 0)) {
    while (queue_count > queue_size)
      if (!try_free_queue(sim->verbose, sim->now()))
        break;
  }
  if (is_monitored())
    sim->record_resource(name, server_count, queue_count, capacity, queue_size);
}
Exemplo n.º 6
0
void Resource::set_capacity(int value) {
  if (capacity == value) return;
  int last = capacity;
  capacity = value;
  if (capacity > last || capacity < 0) {
    // serve another
    while (queue_count) 
      if (!try_serve_from_queue(sim->verbose, sim->now())) break;
  } else if (capacity < last) {
    while (server_count > capacity) 
      if (!try_free_server(sim->verbose, sim->now())) break;
  }
  if (is_monitored()) observe(sim->now());
}
Exemplo n.º 7
0
bool Resource::erase(Arrival* arrival, bool stay) {
  if (stay) {
    int amount = remove_from_server(false, sim->now(), arrival, -1);
    server_count += amount;
    return false;
  }

  if (!remove_from_queue(sim->verbose, sim->now(), arrival)) {
    release(arrival, -1);
    return false;
  }

  if (is_monitored())
    sim->record_resource(name, server_count, queue_count, capacity, queue_size);
  return true;
}
Exemplo n.º 8
0
void Resource::set_capacity(int value) {
  if (capacity == value)
    return;
  int last = capacity;
  capacity = value;
  if (last >= 0  && (capacity > last || capacity < 0)) {
    // serve another
    while (queue_count)
      if (!try_serve_from_queue(sim->verbose, sim->now()))
        break;
  } else if (last < 0 || capacity < last) {
    while (server_count > capacity)
      if (!try_free_server(sim->verbose, sim->now()))
        break;
  }
  if (is_monitored())
    sim->record_resource(name, server_count, queue_count, capacity, queue_size);
}
Exemplo n.º 9
0
// ---------------------------------------------------------------------
//  exactCounters   
// ---------------------------------------------------------------------
// update counters in HCCT with exact frequencies
// during the visit, also computes max and avg counter error among hot nodes
void exactCounters(cct_node_t* root, cct_node_t* cct_root,
                   float *maxError, float *sumError,
                   UINT32 stream_threshold, int (*is_monitored)(cct_node_t* node),
                   UINT32 cct_threshold, UINT32 *falsePositives,
                   float adjustBursting) { 
    cct_node_t* child, *cct_child;
    float childError;
    
    *maxError = 0;
    
    if (root==NULL) return;
    if (cct_root==NULL) 
        panic("Failed CCT vs. HCCT comparison: cannot update counters");

    if (is_monitored(root)) {
        if (cct_root->counter >= cct_threshold ) {
            #if LSS_ADJUST_EPS==1
            // eps in bytes 24-27 of lss_hcct_node_t
            float adjustedCounter = (root->counter - *(((UINT32*)root)+6)) * adjustBursting;
            #else
            float adjustedCounter = root->counter * adjustBursting;
            #endif
            *maxError = (cct_root->counter > adjustedCounter) ? 
                     (cct_root->counter - adjustedCounter)*100.0/cct_root->counter : 
                     (adjustedCounter - cct_root->counter)*100.0/cct_root->counter ;
            *sumError += *maxError;
        }
        else if (root->counter >= stream_threshold) (*falsePositives)++;
    }
    
    root->counter = cct_root->counter;     
   
    for (child=root->first_child; child!=NULL; child=child->next_sibling) { 
        for (cct_child=cct_root->first_child; cct_child!=NULL; 
             cct_child=cct_child->next_sibling) 
            if (cct_child->routine_id == child->routine_id &&
                cct_child->call_site == child->call_site) break;
        exactCounters(child, cct_child, &childError, sumError, stream_threshold, 
                        is_monitored, cct_threshold, falsePositives, adjustBursting);
        if (childError > *maxError) *maxError = childError;
    }        
}
Exemplo n.º 10
0
int Resource::seize(Arrival* arrival, int amount) {
  int status;
  // serve now
  if (room_in_server(amount, arrival->order.get_priority())) {
    insert_in_server(sim->verbose, sim->now(), arrival, amount);
    status = SUCCESS;
  }
  // enqueue
  else if (room_in_queue(amount, arrival->order.get_priority())) {
    insert_in_queue(sim->verbose, sim->now(), arrival, amount);
    status = ENQUEUE;
  }
  // reject
  else {
    if (sim->verbose) verbose_print(sim->now(), arrival->name, "REJECT");
    return REJECT;
  }

  arrival->register_entity(this);
  if (is_monitored())
    sim->record_resource(name, server_count, queue_count, capacity, queue_size);
  return status;
}
Exemplo n.º 11
0
void Resource::set_queue_size(int value) {
  if (queue_size == value) return;
  queue_size = value;
  if (is_monitored()) observe(sim->now());
}