Пример #1
0
  synchronized CacheEntry findVictim(boolean forUncache) {
    Item victim = findMin();
    if (forUncache) entries.remove(victim);
    return victim.entry;

    int id_out;

    FreeSlots++;

    if (A1in.getLength() > Kin) {
      Job A1inTail = A1in.DequeueFront();
      id_out = A1inTail.JobID();

      Job headerJob = new Job(id_out, 1);
      A1out.EnqueueJob(0, headerJob);

      if (A1out.getLength() > Kout) {
        Job removedHeader = A1out.DequeueFront();
        removedHeader = null;
      }
      // put X into the reclaimed page slot
      return A1inTail;
    } else {
      Job AmTail = Am.DequeueFront();
      // put X into the reclaimed page slot
      return AmTail;
    }
  }
Пример #2
0
  public Job Reclaim(int id) {
    Job newjob = new Job(id, 1);
    int id_out;

    if (FreeSlots > 0) {
      // put X into a free page slot
      return newjob;
    } else {
      if (A1in.getLength() > Kin) {
        Job A1inTail = A1in.DequeueFront();
        id_out = A1inTail.JobID();
        // delete A1inTail; ??? paged out of A1in buffer (but may still need to keep the job)

        Job headerJob = new Job(id_out, 1);
        A1out.EnqueueJob(0, headerJob);

        if (A1out.getLength() > Kout) {
          Job removedHeader = A1out.DequeueFront();
          removedHeader = null;
        }
        // put X into the reclaimed page slot
        return newjob;
      } else {
        Job AmTail = Am.DequeueFront();
        AmTail = null;
        // put X into the reclaimed page slot
        return newjob;
      }
    }
  }