Professional Documents
Culture Documents
Green University of Bangladesh: Department of Computer Science and Engineering
Green University of Bangladesh: Department of Computer Science and Engineering
Green University of Bangladesh: Department of Computer Science and Engineering
Green University of
Bangladesh
Course Code:CSE-310
Course Title: Operating System Lab
LAB FINAL
a) Assuming demand paging with three frames, write a program to find the page faults
12/2/2020 1|Page
that would occur for the n number of page references.
Code
#include<stdio.h>
#include<conio.h>
main()
{
printf(" \t \t \t \t LRU CODE \n \n");
12/2/2020 2|Page
{
cnt[i]=0;
frame[i]=-1;
}
{
if(frame[j]==page[i])
{
flag[i]=1;
cnt[j]=next;
next++;
}
}
if(flag[i]==0)
if(i<f)
12/2/2020 3|Page
{
frame[i]=page[i];
cnt[i]=next;
next++;
}
else
{
m=0;
for(j=1; j<f; j++)
if(cnt[m] > cnt[j])
m=j;
frame[m]=page[i];
cnt[m]=next;
next++;
}
pf++;
12/2/2020 4|Page
if(flag[i]==0)
printf("Page faults number = %d", pf);
printf("\n");
}
return 0;
}
Output
12/2/2020 5|Page
b) Write a Bash Program to find all the vowels in a given Sting ‘massage’ and replace
them with ‘V’. Then store those vowels in an array called ‘VOWEL’.
Code
input='massage'
declare -a VOWEL
temp=${input[@]/a/V}
VOWEL=($VOWEL a)
temp2=${temp[@]/a/V}
12/2/2020 6|Page
VOWEL=($VOWEL,a)
temp3=${temp2[@]/e/V}
VOWEL=($VOWEL,e)
12/2/2020 7|Page