Green University of Bangladesh: Department of Computer Science and Engineering

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Department of Computer Science and Engineering

Green University of
Bangladesh

Department of Computer Science and Engineering

Course Code:CSE-310
Course Title: Operating System Lab
LAB FINAL

Submitted By: Submitted To:

Name: MD Shariful Islam


Md. MS. UMME HABIBA
ID: 181002182
Dept. of CSE
Section: Day A
Green University of Bangladesh
Dept.: CSE

Date of Submission: 10-01-2021

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");

int i,j,f, m,page[20],frame[20],cnt[20],k,p,flag[20],pf=0,next=1;

printf("Put the total number of pages: ");


scanf("%d",&p);
printf("Enter the pages reference : \n ");
for(i=0; i<p; i++)
{
scanf("%d",&page[i]);
flag[i]=0;
}

printf("Enter the total number of frames : \n");


scanf("%d",&f);

for(i=0; i<f; i++)

12/2/2020 2|Page
{
cnt[i]=0;
frame[i]=-1;
}

printf("Below Page Replacement process is : \n");


for(i=0; i<p; i++)
{

for(j=0; j<f; j++)

{
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++;

for(j=0; j<f; j++)


printf("%d\t", frame[j]);

12/2/2020 4|Page
if(flag[i]==0)
printf("Page faults number = %d", pf);
printf("\n");
}

printf("\n The number of page faults: %d", pf);

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)

echo "Replace them with ‘V’. than : " $temp3

echo "‘VOWEL’ aray :" $VOWEL

12/2/2020 7|Page

You might also like