Ejemplo n.º 1
0
  public void objectIsToBeEvicted(CacheEvent e) {
    // modify the page table entry
    CacheEntry cacheEntry = e.getCache().getEntry(e.getIndex());
    if (cacheEntry == null) {
      // prev removed by another thread(page aging , PFF)
      Logger.log("SYNC meth put DMPTM ");
      return;
    }
    int vpnNBits =
        ConfigHolder.generalCfg.getVirtualAddrNBits()
            - ConfigHolder.cacheCfgs[ConfigHolder.numberCaches].getBlockSizeNBits(
                cacheEntry.getState());

    // pid not needed
    int[] offsetsLength =
        ((DirectMappedPageTableConfig) ConfigHolder.pageTableCfg.getAddCfg()).getOffsetsLength();
    int vPN = ((ExtCacheEntry) e.getCache().getEntry(e.getIndex())).getValue();
    if (tlbModel.getCfg().isEnabled()) {
      tlbModel.getCache().removeEntry(e.getCache().getEntry(e.getIndex()));
    }
    int[] offsets = getOffsets((int) (vPN % Math.pow(2, vpnNBits)), cacheEntry.getState());
    int lastNumber = 0;
    AbstractTableModel model;
    DirectPageDirectoryEntry entry;
    int n;
    for (int i = 0; i < offsetsLength.length + 1; i++) {
      n = (i == 0 ? (int) (vPN / Math.pow(2, vpnNBits)) : offsets[i - 1]);

      model = tables[i].get(lastNumber);
      entry = ((DirectPageDirectoryModel) model).readEntry(n);
      if (entry == null) {
        System.out.println("ENTRY NULL page must be in page table entry");
      } else {
        if (i == offsetsLength.length) {
          ((DirectPageTableModel) model).setEntryInMemory(n, false);
        } else {
          lastNumber = entry.getPageNumber();
        }
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * @param indexPageTable the index in the table array of level startLevel
  * @param startLevel
  * @param pid
  * @param vPN
  * @param instrType
  * @param ptVPNs
  * @return
  */
 private int getPhysicalPageNumberFromPageTD(
     int indexPageTable,
     int startLevel,
     int pid,
     int vPN,
     short instrType,
     Stack<Integer> ptVPNs) {
   int[] offsetsLength =
       ((DirectMappedPageTableConfig) ConfigHolder.pageTableCfg.getAddCfg()).getOffsetsLength();
   int vpnNBits =
       ConfigHolder.generalCfg.getVirtualAddrNBits()
           - ConfigHolder.cacheCfgs[ConfigHolder.numberCaches].getBlockSizeNBits(instrType);
   int lastNumber = indexPageTable;
   DirectPageDirectoryModel model;
   DirectPageDirectoryEntry entry;
   int[] offsets = getOffsets((int) (vPN % Math.pow(2, vpnNBits)), instrType);
   /*System.out.println("getPhysicalPageNumberFromPageTD instrType=" + String.valueOf(instrType) + ", offsets:");
   for(int i = 0; i < offsets.length; i++){
   	System.out.print(String.valueOf(offsets[i]) + " ");
   }
   System.out.println("");
   */
   int n;
   for (int i = startLevel; i < offsetsLength.length + 1; i++) {
     n = (i == 0 ? (int) (vPN / Math.pow(2, vpnNBits)) : offsets[i - 1]);
     if (lastNumber < 0) {
       System.out.println("Level " + i);
     }
     model = tables[i].get(lastNumber);
     entry = model.readEntry(n);
     if (entry == null) {
       model.newEntry(n);
       if (i == offsetsLength.length) {
         // read first time from disk
         lastNumber = getPageFromDisk(pid, -1, instrType, vPN);
         // System.out.println("getPhysicalPageNumberFromPageTD instrType=" +
         // String.valueOf(instrType) + ", lastNumber1=" + String.valueOf(lastNumber));
         // put the key , value in a swap file
         ((DirectPageTableModel) model).setEntry(n, lastNumber, true);
       } else {
         lastNumber = tables[i + 1].size();
         // System.out.println("getPhysicalPageNumberFromPageTD instrType=" +
         // String.valueOf(instrType) + ", lastNumber3=" + String.valueOf(lastNumber));
         model.setEntryPageNumber(n, lastNumber);
         createTable(i + 1);
       }
     } else {
       if (i == offsetsLength.length) {
         // check if it is in a swap file
         if (!((PageTableEntry) entry).isInMemory()) {
           // the page number is an offset of a swap file, get from
           // there
           lastNumber = getPageFromDisk(pid, -1, instrType, vPN);
           // System.out.println("getPhysicalPageNumberFromPageTD instrType=" +
           // String.valueOf(instrType) + ", lastNumber2=" + String.valueOf(lastNumber));
           ((DirectPageTableModel) model).setEntry(n, lastNumber, true);
         } else {
           lastNumber = entry.getPageNumber();
           // System.out.println("getPhysicalPageNumberFromPageTD instrType=" +
           // String.valueOf(instrType) + ", lastNumber5=" + String.valueOf(lastNumber));
         }
       } else {
         lastNumber = entry.getPageNumber();
         // System.out.println("getPhysicalPageNumberFromPageTD instrType=" +
         // String.valueOf(instrType) + ", lastNumber4=" + String.valueOf(lastNumber));
       }
     }
     if (ptVPNs != null && i > 0) {
       tlbModel
           .getCache()
           .put(new ExtCacheEntry(pid, ptVPNs.pop().intValue(), instrType, lastNumber));
     }
   }
   return lastNumber;
 }