Os Final Project VM
Os Final Project VM
Os Final Project VM
REPLACEMENT
GROUP MEMBERS:
1. MUHAMMAD HAFIZ BIN MUSTAVUDEEN 192018
2. NURFATIN AININA BINTI ISHAK 192704
3. IKHWAN SALIHIN BIN KHAWARI 196553
4. EZZAH MAWADAH BINTI SAIFULBAHRI 197667
INTRODUCTION
When a page fault occurs, the process needs to find the page that caused the page fault in disk. If there is a free space
in main memory it will put in this area. If there isn’t free space it is necessary to make a page replacement with the
algorithm that is implemented. After that the page that is removed will be written in disk. Then the process can
continue the job, because the required page is in the main memory and the process can read it.
There are many page replacement algorithms such as: The Optimal, The Not Recently Used (NRU), The Not
Frequently Used (NFU), The First-in-First-out (FIFO), The Second Chance, The Clock, The Least Recently Used
(LRU), Aging, The Working Set, The Working Set Clock that are available in memory management (Windows
Internal Book).
OVERALL DESCRIPTION OF THE
TECHNIQUE
• The First-in-First-out Algorithm (FIFO)
• the pages are loaded in the main memory. If the page is in the memory, we pass in the other page and n is
increase by one.
• When a process requires a page that isn’t in the memory, a page fault occurs. A page replacement needs to be in
action. Which page chooses FIFO to replace? FIFO selects the page that is entered the first in main memory.
FIFO removes the page that is older.
• In table below is shown how FIFO works. A sequence with 8 number of pages and a page frame with size = 3 is chosen.
• In the fourth step doesn’t happen any replacement, because the page is in the memory. In the fifth step, page 2 that was
placed the first is replaced by page 1.
• The Optimal Algorithm
• At the first step, pages are loaded from the disk to main memory. How many page frames?! The number of page
frames is defined from the capacity of memory and they are loaded to invoke memory until it is full. When a
page fault occurs, a page needs to be swapped (Figure 2). The operating system swaps out the page, whose next
use will occur farthest in the future.
• For example, a page that is not going to be used for the next 2 seconds will be swapped out over a page that is
not going to be used for the next 0.8 seconds. Table 2 shows how the Optimal algorithm works. The same
sequence with 8 number of pages and a page frame with size = 3 is chosen.
• In the fourth step the page 2 is in the memory. In the fifth step the page 2 is replaced with page 1.
• LRU page replacement algorithm
• When a page fault occurs throw out (swapped) the page, that isn’t used for a long time. Page that is swapped
from memory is the page with small counter. This is shown in the flowchart diagram in Figure 3. The page,
which instructions haven’t been executed for a long time, is replaced. To implement LRU is chosen a linked list
to keep all pages in memory, with most recently used page at the front and least recently used page at the tail .
• Table 3 shows how the LRU algorithm works. The same sequence with 8 number of pages and a page frame
with size = 3 is chosen.
• In the fourth step doesn’t happen any replacement because the page is in the memory. In the fifth step page 3,
that is used at least, is replaced by page 1.
DETAILED DESCRIPTION OF
IMPLEMENTATION
• The number of page faults of three algorithms is tested (FIFO, LRU and Optimal) by entering the same number of
pages, the same sequence and the same page frame in main memory.
• 4.1 Environment
• Windows 8.1 operating system is chosen. Eclipse is used to compile and execute the application.
• 4.2 Test phase
• A random sequence of numbers is chosen, because the application generates different sequences, and the
purpose is to test the performance of the three algorithms with the same sequence. Thus, the following
sequence is chosen:
• 85625354235326256856234213754315
• and it is used for respectively 8 pages, 16 pages, 24 pages and 32 pages.
In the first step the program requires the number of pages that are pretended to
be in main memory. After that, it requires to put the sequence of the pages. In
the next step, a menu is printed. A choice can be make. The number of frames
is entered, that is the capacity of the main memory. The application shows for
each step the pages that are currently in main memory and the number of page
faults. A table with number of page faults, for each algorithm, with page frame
size = 3 and with respectively 8 pages, 16 pages, 24 pages and 32 pages is
generated.
Algorithm\No 8 16 24 32
pages
FIFO 7 12 18 25
LRU 6 11 15 23
Optimal 6 8 12 16
CONCLUSION