Example #1
0
 public static void readPage(int spn, int ppn) {
   if (allocatedPages.contains(spn)) {
     swapLock.acquire();
     swapFile.read(spn * PAGESIZE, memory, ppn * PAGESIZE, PAGESIZE);
     swapLock.release();
   } else {
   }
 }
Example #2
0
 public static int insertPage(int spn, int ppn) {
   swapLock.acquire();
   int numBits = swapFile.write(spn * PAGESIZE, memory, ppn * PAGESIZE, PAGESIZE);
   // assert that numBits == PAGESIZE
   allocatedPages.add(spn);
   swapLock.release();
   return spn;
 }
Example #3
0
 public static void free(int page) {
   swapLock.acquire();
   freePages.add(page);
   swapLock.release();
 }