Page Replacement technique is used to replace page in memory frame with in os . The popular 3 approaches are
- FIFO
- LRU
- Optimal
- Initialize an empty frame of size frames.
- Set pageFault = 0 and frameCount = 0.
- For each page in the pages array:
- If the page is not in the frame:
- Replace the page at frameCount with the current page.
- Increment frameCount (modulo the frame size for circular replacement).
- Increment pageFault.
- If the page is already in the frame, do nothing.
- At the end, return pageFault.
- Initialize an empty frame of size frames.
- Maintain a list of recently used pages.
- Set pageFault = 0.
- For each page in the pages array:
- If the page is not in the frame:
- If the frame is full, remove the least recently used page (the one at the front of the list).
- Add the page to the frame and the end of the list.
- Increment pageFault.
- If the page is already in the frame:
- Update the recently used list by moving the page to the end.
- If the page is not in the frame:
- At the end, return pageFault.
- Initialize an empty frame of size frames.
- Set pageFault = 0.
- For each page in the pages array (current index i):
- If the page is not in the frame:
- If the frame is full, find the page that will not be used for the longest period of time:
- Look ahead in the pages array to see when each page in the frame will next be used.
- Replace the page with the largest index or the one not used at all.
- Add the page to the frame.
- Increment pageFault.
- If the page is already in the frame, do nothing.
- If the page is not in the frame:
- At the end, return pageFault.
- Java
- Java environment (vs code , notepad++,eclipse)
Important
Import Java modules correctly and change the package part in the file