lp1 Assigment4
lp1 Assigment4
:4
Problem Statement:
Write a Java Program (using OOP features) to implement paging simulation using
1. FIFO
3. Optimal algorithm
Objectives:
Theory:
1. Page Fault: Absence of page when referenced in main memory during paging leads to a page
fault.
2. Page Replacement: Replacement of already existing page from main memory by the required new
page is called as page replacement. And the techniques used for it are called as page replacement
algorithms.
Page replacement is used primarily for the virtual memory management because in virtual memory
paging system principal issue is replacement i.e. which page is to be removed so as to bring in the
new page, thus the use of the page replacement algorithms. Demand paging is the technique used
to increase system throughput. To implement demand paging page replacement is primary
requirement. If a system has better page replacement technique it improves demand paging which
in turn drastically yields system performance gains.
2) if no free frame found, use page replacement algorithm to select a victim frame.
3. Read the desired page into the new free frame, change the page and frame tables. 4. Restart the
user process.
PAGE REPLACEMENT ALGORITHMS:
1. FIFO
This is the simplest page replacement algorithm. In this algorithm, the operating system keeps track
of all pages in the memory in a queue, the oldest page is in the front of the queue. When a page
needs to be replaced page in the front of the queue is selected for removal.
Replace the page that will not be used for longest period of time as compared to the other pages in
main memory. An optimal page replacement algorithm has lowest page fault rate of all algorithm. It
is called as OPT or MIN.
ADVANTAGE:
1) This algorithm guarantees the lowest possible page-fault rate for a fixed no. of frames.
DISADVANTAGE:
1) The optimal page replacement algorithm is very difficult to implement, as it requires the
knowledge of reference strings i.e. strings of memory references
LRU algorithm uses the time of the page’s last usage. It uses the recent past as an approximation of
the near future, then we can replace the page that has not been used for the longest period of the
time i.e. the page having larger idle time is replaced.
ADVANTAGE:
1) The LRU policy is often used for page replacement and is considered to be good.
DISADVANTAGES:
3) The problematic determination of the order for the frames defined by the time of last usage
Algorithm/Flowchart:
1. FIFO :
3. OPTIMAL ALGORTHIM:
1. Start Program
6. If No Frames Is Free Replace The Page With The Page That Is Least Used 7.Print Page Number Of
Page Faults
8.Stop process.
Input:
1. Number of frames
2. Number of pages
3. Page sequence
Output:
Test Cases:
1. Test the page hit and miss ratio for different size of page frames.
2. Test the page hit and miss ratio for both algorithms with different page sequences.
Software Requirement:
1. Fedora
2. Eclipse
3. JDK
Hardware Requirement: