0% found this document useful (0 votes)
16 views3 pages

Osy Exp 15

The code implements the FIFO page replacement algorithm on a sample page reference string. It takes the number of pages and frames as input, stores the reference string in an array, and initializes another array to track the frames. It iterates through the reference string, checks for page hits in frames, increments page faults, and replaces the oldest page based on FIFO. The output prints the frames at each step and total page faults.

Uploaded by

Paras Kamble
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Osy Exp 15

The code implements the FIFO page replacement algorithm on a sample page reference string. It takes the number of pages and frames as input, stores the reference string in an array, and initializes another array to track the frames. It iterates through the reference string, checks for page hits in frames, increments page faults, and replaces the oldest page based on FIFO. The output prints the frames at each step and total page faults.

Uploaded by

Paras Kamble
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

OSY EXP 15

Program Code :
Q1) Implement FIFO Page Replacement algorithm on following Page Reference Stream:
1 2 3 2 1 5 2 1 6 2 5 6 3 1 3 6 1 2 4 3
CODE:
#include<stdio.h>
int main(){
int reference_string[10], page_faults = 0, m, n, s, pages, frames;
printf("\nHawaiza Siddiqui 19431\t");
printf("\nEnter Total Number of Pages:\t");
scanf("%d", &pages);
printf("\nEnter values of Reference String:\n");
for(m = 0; m < pages; m++){
printf("Value No. [%d]:\t", m + 1);
scanf("%d", &reference_string[m]); }
printf("\nEnter Total Number of Frames:\t");
scanf("%d", &frames);
int temp[frames];
for(m = 0; m < frames; m++){
temp[m] = -1;}
for(m = 0; m < pages; m++){
s = 0;
for(n = 0; n < frames; n++){
if(reference_string[m] == temp[n]){
s++;
page_faults--; }}
page_faults++;
if((page_faults <= frames) && (s == 0)){
temp[m] = reference_string[m];}
else if(s == 0)
temp[(page_faults - 1) % frames] = reference_string[m];
printf("\n");
for(n = 0; n < frames; n++)
{
printf("%d\t", temp[n]);
}
}
printf("\nTotal Page Faults:\t%d\n", page_faults);
return 0;
}
OUTPUT:
OSY EXP 15
OSY EXP 15

You might also like