Example #1
0
//void
//int prio;
//float ratio;
void upgrade_process_prio(int prio,float ratio)
{
    int count;
    int n;
    Ele *proc;
    List *src_queue, *dest_queue;

    if (prio >= MAXPRIO)
    {
        return;
    }
    src_queue = prio_queue[prio];
    dest_queue = prio_queue[prio+1];
    count = src_queue->mem_count;

    if (count > 0)
    {
        n = (int) (count*ratio + 1);
        proc = find_nth(src_queue, n);
        if (proc)
        {
            src_queue = del_ele(src_queue, proc);
            /* append to appropriate prio queue */
            proc->priority = prio;
            dest_queue = append_ele(dest_queue, proc);
        }
    }
}
Example #2
0
schedule() {
  int i;

  cur_proc = NULL;
  for (i=MAXPRIO; i > 0; i--) {
    if (prio_queue[i]->mem_count > 0) {
      cur_proc = prio_queue[i]->first;
      prio_queue[i] = del_ele(prio_queue[i], cur_proc);
      return;
    }
  }
}
Example #3
0
void unblock_process(float ratio) {
  int count;
  int n;
  Ele *proc;
  int prio;

  if (block_queue) {
    count = block_queue->mem_count;
    n = (int) (count*ratio + 1);
    proc = find_nth(block_queue, n);
    if (proc) {
      block_queue = del_ele(block_queue, proc);
      prio = proc->priority;
      prio_queue[prio] = append_ele(prio_queue[prio], proc);
    }
  }
}