Esempio n. 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;
    }
  }
Esempio n. 2
0
  synchronized void addEntry(CacheEntry entry) {
    count++;
    entries.add(new Item(entry, (double) count));

    FreeSlots--;
    count++;

    if (A1out.getJob(job.JobID()) != null) {
      // reclaimed = Reclaim(id);
      // Am.EnqueueJob(0, reclaimed);
      Am.EnqueueJob(0, job);
    } else {
      if (A1in.getJob(job.JobID()) != null) {
        // do nothing
      } else {
        // reclaimed = Reclaim(id);
        // A1in.EnqueueJob(0, reclaimed);
        A1in.EnqueueJob(0, job);
      }
    }

    // pq.EnqueueJob((double)count, job);
    incrUsed(job.JobSize());
  }