Os Labreport
Os Labreport
Lab No. 01
Title: WAP to simulate FIFO page replacement algorithm with user input frame size and
reference string.
First In First Out (FIFO):
The simplest algorithm for replacing pages is this one. The operating system maintains a queue
for all of the memory pages in this method, with the oldest page at the front of the queue. The
first page in the queue is chosen for removal when a page has to be replaced.
Algorithm:
1. Start the process
4. Check the need of replacement from old page to new page in memory
Output:
Date: 4/30/2023
Lab No: 03
Title: WAP to simulate LRU page replacement algorithm with user input frame size and
reference string.
Least Recently Used(LRU):
Least Recently Used(LRU) algorithm is a page replacement technique used for memory
management. According to this method, the page which is least recently used is replaced.
Therefore, in memory, any page that has been unused for a longer period of time than the others
is replaced.
Algorithm:
1. Start
2. Initialize an empty array called "frames" of size n.
3. Initialize an array called "pages" of size m
4. Initialize variables pageHits and pageFaults to 0.
5. For each page in the "pages" array:
a. Set variable "pageFound" to 0.
b. For each frame in the "frames" array:
i. If the current page is already in memory, set "pageFound" to 1 and break out of the loop.
c. If "pageFound" is 0:
i. Increment "pageFaults".
ii. Find the frame in "frames" that was least recently used (LRU).
iii. Replace the LRU frame with the current page.
d. If "pageFound" is 1, increment "pageHits".
6. Print the total number of page hits and page faults.End of the algorithm.
Output: