OS LAB R20 (2)
OS LAB R20 (2)
Regulation : R20
Year/Semester : II/I
Academic Year : 2022-23
Branch : CSE
Course Outcomes:
To use Unix utilities and perform basic shell control of the utilities
To use the Unix file system and file access control
To use of an operating system to develop software
Students will be able to use Linux environment efficiently
Solve problems using bash for shell scripting
OPERATING SYSTEM LAB
LIST OF EXPERIMENTS
1) a) Study of Unix/Linux general purpose utility command list: man,who,cat, cd, cp, ps, ls,
mv, rm, mkdir, rmdir, echo, more, date, time, kill, history, chmod, chown, finger, pwd, cal, logout,
shutdown.
b) Study of vi editor
c) Study of Bash shell, Bourne shell and C shell in Unix/Linux operating system
d) Study of Unix/Linux file system (tree structure)
e) Study of .bashrc, /etc/bashrc and Environment variables.
2) Write a C program that makes a copy of a file using standard I/O, and system calls
3) Write a C program to emulate the UNIX ls –l command.
4) Write a C program that illustrates how to execute two commands concurrently with a command
pipe. Ex: - ls –l | sort
5) Simulate the following CPU scheduling algorithms: (a) Round Robin (b) SJF (c) FCFS (d)
Priority
6) Multiprogramming-Memory management-Implementation of fork (), wait (), exec() and exit (),
System calls
7) Simulate the following: a) Multiprogramming with a fixed number of tasks (MFT) b)
Multiprogramming with a variable number of tasks (MVT)
8) Simulate Bankers Algorithm for Dead Lock Avoidance
9) Simulate Bankers Algorithm for Dead Lock Prevention.
10) Simulate the following page replacement algorithms: a) FIFO b) LRU c) LFU
11) Simulate the following File allocation strategies (a) Sequenced (b) Indexed (c) Linked
12) Write a C program that illustrates two processes communicating using shared memory
13) Write a C program to simulate producer and consumer problem usingsemaphores
14) Write C program to create a thread using pthreads library and let it run its function.
15) Write a C program to illustrate concurrent execution of threads using pthreads library
ADDITIONAL EXPERIMENTS
- It is also called as UNIX File System, because it is used to organize UNIX files.
- The different directories in the Directory Hierarchy are,
d) Study of .bashrc, /etc/bashrc and Environment variables.
.bashrc
.bashrc file is automatically executed when new terminal(shell) is opened. Purpose of
bashrc file:
You can export environment variables(So there is no need to export
environment variable every time)
You can define aliases. You can provide the path for cross compiler. You can add your own
script which can start automatically whenever
new shell is opened.
You can change the history length
/etc/bashrc
Like .bash_profile you will also commonly see a .bashrc file in your home
directory. This file is meant for setting command aliases and functions used by bash
shell users.
Just like the /etc/profile is the system wide version of .bash_profile. The
/etc/bashrc for Red Hat and /etc/bash.bashrc in Ubuntu is the system wide version of
.bashrc.
Interestingly enough in the Red Hat implementation the /etc/bashrc also executes the shell
scripts within /etc/profile.d but only if the users shell is a Interactive Shell (aka Login
Shell)
Environment Variables:
variable purpose
PATH The PATH variable holds a list of directories in a certain order. In this
list colon {:) separate different directories
HOME When a user logs in, he or she will be automatically placed in the home
directory. This directory is decided by the system administrator at the
time of opening an account for a user.This directory is stored in the file
/etc/passwd
IFS This variable holds tokens used by the shell commands to parse a
string
into substrings such as a word or a record into its individual fields. The
default tokens are the three white space tokens Space, Tab, New line
MAIL This variable holds the absolute pathname of the file where user’s
mail
is kept. Usually the name of this file is the user’s login name
SHELL This variable contains the name of the users shell program in the form
of
absolute pathname. System administrator sets the default shell If
required, user can change it
TERM This variable holds the information regarding the type of the terminal
being used. If TERM is not set properly, utilities like vi editor will
not
work
2) Write a C program that makes a copy of a file using standard I/O, and system
#include <unistd.h>
#include <fcntl.h>
void typefile (char *filename)
{
int fd, nread;
char buf[1024];
fd = open (filename, O_RDONLY);
if (fd == -1)
{
perror (filename);
return;
}
while ((nread = read (fd, buf, sizeof (buf))) > 0)
write (1, buf, nread);
close (fd);
}
int main (int argc, char **argv)
{
int argno;
for (argno = 1; argno<argc; argno++)
typefile (argv[argno]);
}
Output:
$cc ioscalls.c
$cat>ff
Hi hello
$./a.out ff
Hi hello
3. Write a C program to emulate the Unix ls-l command.
#include <stdio.h> #include
<unistd.h> #include
<sys/types.h> #include
<sys/wait.h> #include
<stdlib.h>
int main()
{
int pid; //process id
pid = fork(); //create another process if (
pid < 0 )
{ //fail
printf(“\nFork failed\n”); exit
(-1);
}
else if ( pid == 0 )
{ //child
execlp ( “/bin/ls”, “ls”, “-l”, NULL ); //execute ls
}
else
{ //parent
wait (NULL); //wait for child
printf(“\nchild complete\n”);
exit (0);
}
}
OUTPUT:
guest-glcbIs@ubuntu:~$gcc –o lsc.out lsc.c
guest-glcbIs@ubuntu:~$./lsc.out
total 100
-rwxrwx—x 1 guest-glcbls guest-glcbls 140 2012-07-06 14:55 f1
drwxrwxr-x 4 guest-glcbls guest-glcbls 140 2012-07-06 14:40 dir1 child
complete
4) Write a program that illustrates how to execute two commands concurrently with a command
pipe
#include <stdio.h> #include
<unistd.h> #include
<sys/types.h> #include
<stdlib.h>
int main()
{
int pfds[2]; char
buf[30];
if(pipe(pfds)==-1)
{
perror("pipe failed");
exit(1);
}
if(!fork())
{
close(1);
dup(pfds[1];
system (“ls –l”);
}
else
{
printf("parent reading from pipe \n");
while(read(pfds[0],buf,80)) printf("%s \
n" ,buf);
}
}
Output:
[student@gcet ~]$ vi pipes2.c
[student@gcet ~]$ cc pipes2.c
[student@gcet ~]$ ./a.out Parent
reading from pipe Total 24
-rwxrwxr-x l student student 5563Aug 3 10:39 a.out
-rw-rw-r—l
Student student 340 jul 27 10:45 pipe2.c
-rw-rw-r—l student student
Pipes2.c
-rw-rw-r—l student student 401 34127 10:27 pipe2.c
student
) Simulate the following CPU scheduling algorithms:
a.SJF
b. FCFS
c.ROUND ROBIN
d. PRIORITY
a.SJF (Non - Preemptive)
#include<stdio.h>
int main()
{
int i,n,p[10]={1,2,3,4,5,6,7,8,9,10},min,k=1,btime=0;
int bt[10],temp,j,at[10],wt[10],tt[10],ta=0,sum=0; float
wavg=0,tavg=0,tsum=0,wsum=0;
printf(" -------Shortest Job First Scheduling ( NP ) ---------\n");
printf("\nEnter the No. of processes :");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\tEnter the burst time of %d process :",i+1);
scanf(" %d",&bt[i]);
printf("\tEnter the arrival time of %d process :",i+1);
scanf(" %d",&at[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(at[i]<at[j])
{
temp=p[j];
p[j]=p[i];
p[i]=temp;
temp=at[j];
at[j]=at[i];
at[i]=temp;
temp=bt[j];
bt[j]=bt[i];
bt[i]=temp;
}
}
}
for(j=0;j<n;j++)
{
btime=btime+bt[j];
min=bt[k];
for(i=k;i<n;i++)
{
if (btime>=at[i] && bt[i]<min)
{
temp=p[k];
p[k]=p[i];
p[i]=temp;
temp=at[k];
at[k]=at[i];
at[i]=temp;
temp=bt[k];
bt[k]=bt[i];
bt[i]=temp;
}
} k+
+;
}
wt[0]=0;
for(i=1;i<n;i++)
{
sum=sum+bt[i-1];
wt[i]=sum-at[i];
wsum=wsum+wt[i];
}
wavg=(wsum/n);
for(i=0;i<n;i++)
{
ta=ta+bt[i];
tt[i]=ta-at[i];
tsum=tsum+tt[i];
}
tavg=(tsum/n);
printf("**********************
**"); printf("\n RESULT:-");
printf("\nProcess\t Burst\t Arrival\t Waiting\t Turn-around" );
for(i=0;i<n;i++)
{
printf("\n p%d\t %d\t %d\t\t %d\t\t\t%d",p[i],bt[i],at[i],wt[i],tt[i]);
}
OUTPUT:
-------Shortest Job First Scheduling ( NP )-------
Enter the No. of processes :3
Enter the burst time of 1 process :4
Enter the arrival time of 1 process :1
Enter the burst time of 2 process :3
Enter the arrival time of 2 process :0
Enter the burst time of 3 process :5
Enter the arrival time of 3 process :2
******************
****** RESULT:-
Process Burst Arrival Waiting Turn-around
p2 3 0 0 3
p1 4 1 2 6
p3 5 2 5 10
b) FCFS:
Algorithm for FCFS scheduling:
Step 1: Start the process
Step 2: Accept the number of processes in the ready Queue
Step 3: For each process in the ready Q, assign the process id and accept the CPU burst time
Step 4: Set the waiting of the first process as ‘0’ and its burst time as its turnaround time
Step 5: for each process in the Ready Q calculate
(a) Waiting time for process(n)= waiting time of process (n-1) + Burst time of process(n-
1)
(b) Turnaround time for Process(n)= waiting time of Process(n)+ Burst time for
process(n)
Step 6: Calculate
(a) Average waiting time = Total waiting Time / Number of process
(b) Average Turnaround time = Total Turnaround Time / Number of process Step
7: Stop the process
PROGRAM:
#include<iostream> using
namespace std; class fcfs
{
int a[10],k,b[10],c[10],d[10],n,i,j,sum,total; float
awt,atat;
public:
void getdata()
{
k=total=sum=0;
cout<<"enter the no of processes:";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"enter the burst time for process:"<<i+1<<" ";
cin>>a[i];
d[i]=i+1;
}
b[0]=0;
for(i=0;i<n;i++)
{
k=k+a[i];
b[i+1]=k;
}
for(i=0;i<n;i++)
{
c[i]=a[i]+b[i];
sum=sum+b[i];
total=total+c[i];
}
awt=sum/n;
atat=total/n;
}
void putdata()
{
cout<<"Process\tBurst time\twaiting time\tTurn around time\n";
for(i=0;i<n;i++)
{
cout<<d[i]<<"\t"<<a[i]<<"\t"<<b[i]<<"\t"<<c[i]<<"\n";
}
cout<<"average waitig time:"<<awt;
cout<<"\nTurn around time:"<<atat;
}
};
int main()
{
fcfs obj;
obj.getdata();
obj.putdata();
return 0;
}
OUTPUT:
enter the no of processes:3
enter the burst time for process:1 2
enter the burst time for process:2 5
enter the burst time for process:3 4
Process Burst time waiting time Turn around time
1 2 0 2
2 5 2 7
3 4 7 11
average waiting time:3
Turn around time:6
2 1 4 0 4
0 2 1 4 5
1 3 1 5 6
#include<stdio.h>
#include<unistd.h>
main( )
{
int i, pid;
pid=fork( );
if(pid== -1)
{
perror("fork failed");
exit(0);
}
else if(pid==0)
{
printf("\n Child process starts"); for(i=0;
i<5; i++)
{
printf("\n Child process %d is called", i);
}
printf("\n Child process ends");
}
else
{
wait(0);
printf("\n Parent process ends");
}
exit(0);
}
OUTPUT
:
Child process starts Child
process 0 is called Child
process 1 is called Child
process 2 is called Child
process 3 is called Child
process 4 is called Child
process ends Parent
process ends
7) a. Multiprogramming with fixed number of tasks (MFT) :
Algorithm:
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int i,m,n,tot,s[20];
printf("Enter total memory size:");
scanf("%d",&tot);
printf("Enter no. of pages:");
scanf("%d",&n);
printf("Enter memory for OS:");
scanf("%d",&m); for(i=0;i<n;i++)
{
printf("Enter size of page%d:",i+1);
scanf("%d",&s[i]);
}
tot=tot-m;
for(i=0;i<n;i++)
{
if(tot>=s[i])
{
printf("Allocate page %d\n",i+1);
tot=tot-s[i];
}
else
printf("process p%d is blocked\n",i+1);
}
printf("External Fragmentation is=%d",tot);
}
Output:
Enter total memory size:50
Enter no. of pages:4
Enter memory for OS:10
Enter size of page1:10
Enter size of page2:9
Enter size of page3:9
Enter size of page4:10
Allocate page 1
Allocate page 2
Allocate page 3
Allocate page 4
External Fragmentation is=2
Multiprogramming with a variable number of task (MVT) :
Algorithm:
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int ms,i,ps[20],n,size,p[20],s,intr=0;
clrscr();
printf("Enter size of memory:");
scanf("%d",&ms);
printf("Enter memory for OS:");
scanf("%d",&s);
ms-=s;
printf("Enter no.of partitions to be divided:");
scanf("%d",&n);
size=ms/n;
for(i=0;i<n;i++)
{
printf("Enter process and process size");
scanf("%d%d",&p[i],&ps[i]);
if(ps[i]<=size)
{
intr=intr+size-ps[i];
printf("process%d is allocated\n",p[i]);
}
else
printf("process%d is blocked",p[i]);
}
printf("total fragmentation is %d",intr); getch();
}
Output:
Enter size of memory:50
Enter memory for OS:10
Enter no.of partitions to be divided:4
Enter process and process size1 10
process1 is allocated
Enter process and process size2 9
process2 is allocated
Enter process and process size3 9
process3 is allocated
Enter process and process size4 8
process4 is allocated
total fragmentation is 4
8,9) Simulate Banker’s Algorithm for Deadlock avoidance & Dead Lock Prevention
#include<stdio.h>
#include<conio.h>
struct da
{
int max[10],a1[10],need[10],before[10],after[10];
}p[10];
void main()
{
int i,j,k,l,r,n,tot[10],av[10],cn=0,cz=0,temp=0,c=0; clrscr();
OUTPUT:
ENTER THE NO. OF PROCESSES:5
PROCESS 1
PROCESS 2
MAXIMUM VALUE FOR
PROCESS 3
PROCESS 4
PROCESS 5
P 2 210 532
P 4 521 743
P 1 000 753
P 3 153 1055
P 5 624 1057
count=0;
}
printf("\n The number of Page Faults using FIFO are %d",pf);
}
OUTPUT:
The Page Replacement Process is –
7 -1 -1 PF No. 1
7 0 -1 PF No. 2
7 0 1 PF No. 3
2 0 1 PF No. 4
201
2 3 1 PF No. 5
2 3 0 PF No. 6
4 3 0 PF No. 7
4 2 0 PF No. 8
4 2 3 PF No. 9
0 2 3 PF No. 10
023
023
0 1 3 PF No. 11
0 1 2 PF No. 12
012
012
7 1 2 PF No. 13
7 0 2 PF No. 14
7 0 1 PF No. 15
The number of Page Faults using FIFO are 15
PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
{
int i, j , k, min, rs[25], m[10], count[10], flag[25], n, f, pf=0, next=1; clrscr();
printf("Enter the length of reference string -- ");
scanf("%d",&n);
printf("Enter the reference string -- ");
for(i=0;i<n;i++)
{
scanf("%d",&rs[i]);
flag[i]=0;
}
printf("Enter the number of frames -- ");
scanf("%d",&f);
for(i=0;i<f;i++)
{
count[i]=0;
m[i]=-1;
}
printf("\nThe Page Replacement process is -- \n");
for(i=0;i<n;i++)
{
for(j=0;j<f;j++)
{
if(m[j]==rs[i])
{
flag[i]=1;
count[j]=next;
next++;
}
}
if(flag[i]==0)
{
if(i<f)
{
m[i]=rs[i];
count[i]=next; next+
+;
}
else
{
min=0;
for(j=1;j<f;j++)
if(count[min] > count[j])
min=j;
m[min]=rs[i];
count[min]=next;
next++;
}
pf++;
}
for(j=0;j<f;j++) printf("%d\
t", m[j]); if(flag[i]==0)
printf("PF No. -- %d" , pf);
printf("\n");
}
printf("\nThe number of page faults using LRU are %d",pf);
getch();
}
INPUT
Enter the length of reference string -- 20
Enter the reference string -- 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
for(i=0;i<n;i++)
{
printf("Enter no. of blocks occupied by file%d",i+1);
scanf("%d",&b[i]);
printf("Enter the starting block of file%d",i+1);
scanf("%d",&sb[i]);
t[i]=sb[i];
for(j=0;j<b[i];j++)
c[i][j]=sb[i]++;
}
printf("Filename\tStart block\tlength\n"); for(i=0;i<n;i++)
printf("%d\t %d \t%d\n",i+1,t[i],b[i]);
printf("Enter file name:");
scanf("%d",&x);
printf("File name is:%d",x);
printf("length is:%d",b[x-1]);
printf("blocks occupied:");
for(i=0;i<b[x-1];i++)
printf("%4d",c[x-1][i]);
}
OUTPUT
:
Enter no.of files:3
Enter no. of blocks occupied by file1 15
Enter the starting block of file1 11
Enter no. of blocks occupied by file2 8
Enter the starting block of file2 3
Enter no. of blocks occupied by file3 4
#include<stdio.h>
#include<conio.h>
main()
{
int n,m[20],i,j,sb[20],s[20],b[20][20],x;
printf("Enter no. of files:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
semaphores. PROGRAM:
#include<std
ioio.h> void
main()
int buffer[10], bufsize, in, out, produce, consume, choice=0; in = 0; out = 0; bufsize
while(choice !=3)
{
printf(“\n1. Produce \t 2. Consume \t3. Exit”); printf(“\
nEnter your choice: ”); scanf(“%d”, &choice);
switch(choice)
{
case 1: if((in+1)%bufsize==out)
printf(“\nBuffer is Full”);
else
{
printf(“\nEnter the value: “);
scanf(“%d”, &produce); buffer[in] =
produce;
in = (in+1)%bufsize;
}
reak;
case 2: if(in == out) printf(“\
nBuffer is Empty”); else
{
consume = buffer[out];
printf(“\nThe consumed value is %d”, consume); out = (out+1)%bufsize;
}
break;
}
} }
OUTPUT
1. Produce 2. Consume 3. Exit
Enter your choice: 2
Buffer is Empty
1. Produce 2. Consume 3. Exit
Enter your choice: 1
Enter the value: 100
1. Produce 2. Consume 3. Exit
Enter your choice: 2
The consumed value is 100
1. Produce 2. Consume 3. Exit
Enter your choice: 3
13) Write a C program that illustrates two processes communicating using shared memory.
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/shm.h>
#include<string.h> int
main()
{
int i;
15) Write a c program to illustrate concurrent executionof threads using pthreads library
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
void *mythread1(void *vargp)
{
int i; printf("thread1\n");
for(i=1;i<=10;i++)
printf("i=%d\n",i);
printf("exit from thread1\n"); return
NULL;
}
void *mythread2(void *vargp)
{
int j; printf("thread2 \
n"); for(j=1;j<=10;j++)
printf("j=%d\n",j);
printf("Exit from thread2\n"); return
NULL;
}
int main()
{
pthread_t tid; printf("before
thread\n");
pthread_create(&tid,NULL,mythread1,NULL);
pthread_create(&tid,NULL,mythread2,NULL);
pthread_join(tid,NULL); pthread_join(tid,NULL);
exit(0);
}
OUT PUT ::
$ cc w8.c – l pthread
$./a.out
thread1
i=1
i=2;
i=3
thread2
j=1
j=2
j=3
j=4
j=5
j=6
j=7
j=8
i=4
i=5
i=6
i=7
i=8
i=9
i=10
exit from thread1 j=9
j=10
exit from thread2
ADDITIONAL EXPERIMENTS
#include <stdio.h>
#include <stdlib.h>
int main(){
int RQ[100], i, j, n, TotalHeadMoment = 0, initial, size, move;
printf("Enter the number of Requests\n");
scanf("%d", &n);
printf("Enter the Requests sequence\n");
for (i = 0; i < n; i++)
scanf("%d", &RQ[i]);
printf("Enter initial head position\n");
scanf("%d", &initial);
printf("Enter total disk size\n");
scanf("%d", &size);
printf("Enter the head movement direction for high 1 and for low 0\n");
scanf("%d", &move);
for (i = 0; i < n; i++){
for (j = 0; j < n - i - 1; j++){
if (RQ[j] > RQ[j + 1]){
int temp;
temp = RQ[j];
RQ[j] = RQ[j + 1];
RQ[j + 1] = temp;
}
}
}
int index;
for (i = 0; i < n; i++){
if (initial < RQ[i]){
index = i;
break;
}
}
if (move == 1){
for (i = index; i < n; i++){
TotalHeadMoment = TotalHeadMoment + abs(RQ[i] - initial);
initial = RQ[i];
}
TotalHeadMoment = TotalHeadMoment + abs(size - RQ[i - 1] - 1);
TotalHeadMoment = TotalHeadMoment + abs(size - 1 - 0);
initial = 0;
for (i = 0; i < index; i++){
TotalHeadMoment = TotalHeadMoment + abs(RQ[i] - initial);
initial = RQ[i];
}
}
else{
for (i = index - 1; i >= 0; i--){
TotalHeadMoment = TotalHeadMoment + abs(RQ[i] - initial);
initial = RQ[i];
}
TotalHeadMoment = TotalHeadMoment + abs(RQ[i + 1] - 0);
TotalHeadMoment = TotalHeadMoment + abs(size - 1 - 0);
initial = size - 1;
for (i = n - 1; i >= index; i--){
TotalHeadMoment = TotalHeadMoment + abs(RQ[i] - initial);
initial = RQ[i];
}
}
printf("Total head movement is %d", TotalHeadMoment);
return 0;
}
b) Linked file allocation:
#include<stdio.h>
#include<conio.h>
struct file
{
char fname[10];
int start,size,block[10];
}f[10];
main()
{
int i,j,n;
printf("Enter no. of files:");
scanf("%d",&n); for(i=0;i<n;i+
+)
{
printf("Enter file name:");
scanf("%s",&f[i].fname);
printf("Enter starting block:");
scanf("%d",&f[i].start);
f[i].block[0]=f[i].start; printf("Enter
no.of blocks:");
scanf("%d",&f[i].size);
printf("Enter block numbers:");
for(j=1;j<=f[i].size;j++)
{
scanf("%d",&f[i].block[j]);
}
}
printf("File\tstart\tsize\tblock\n");
for(i=0;i<n;i++)
{
printf("%s\t%d\t%d\t",f[i].fname,f[i].start,f[i].size);
for(j=1;j<=f[i].size-1;j++)
printf("%d--->",f[i].block[j]);
printf("%d",f[i].block[j]);
printf("\n");
}
}
Enter no. of
OUTP files:2 Enter
UT:
f lock:20 Enter
i no.of blocks:6
l Enter block
e numbers:4 12
15 45 32 25
n Enter file
a name:bunny
m Enter starting
e block:12 Enter
: no.of blocks:5
s Enter block numbers:6 5 4 3 2
u File start size block
n sunny 20 6 4--->12--->15--->45--->32--->25
n bunny 12 5 6--->5--->4--->3--->2
y
E
n
t
e
r
s
t
a
r
t
i
n
g
b
201
2 0 3 PF No. -- 5
203
4 0 3 PF No. -- 6
4 0 2 PF No. -- 7
4 3 2 PF No. -- 8
0 3 2 PF No. -- 9
032
032
1 3 2 PF No. -- 10
132
1 0 2 PF No. -- 11
102
1 0 7 PF No. -- 12
107
107
The number of page faults using LRU are 12
INPUT
OUTPUT
The Page Replacement Process is –
1 -1 -1 PF No. 1
1 2 -1 PF No. 2
1 2 3 PF No. 3
4 2 3 PF No. 4
5 2 3 PF No. 5
523
523
5 2 1 PF No. 6
5 2 4 PF No. 7
5 2 3 PF No. 8
Total number of page faults -- 8