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