0% found this document useful (0 votes)
3 views2 pages

Osy Exp 15

Uploaded by

ansarianam030
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)
3 views2 pages

Osy Exp 15

Uploaded by

ansarianam030
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/ 2

OSY EXP 15 Hawaiza Siddiqui 19431

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 Hawaiza Siddiqui 19431

You might also like