Esempio n. 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 {
   }
 }
Esempio n. 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;
 }
Esempio n. 3
0
 public static void free(int page) {
   swapLock.acquire();
   freePages.add(page);
   swapLock.release();
 }