Professional Documents
Culture Documents
Session 2020-21
INDEX
ii
a) Optimal
iv
Faculty Signature:
Marks:
128 bytes
255 bytes
32 bytes
64 bytes
info
man
v
None of these
Both a and b
Ubuntu
Redhat
CentOs
BSD
uname -r
kernel
uname -n
uname –s
5.Which command is used to list all the files in your current directory(including hidden)?
ls -l
ls -t
ls -a
ls –i
rmdir
rm -r
vi
only b
Both a and b
touch
cat
echo
Commands:
vii
EXPERIMENT NO. 3
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Sem ECE
Link to Code:
Date: 10/02/2021
Faculty Signature:
Marks:
1.
(A) 0
(B) 1
(C) 10
(D) undefined
2.
(A)
(B)
(C)
(D)
3.
(A) 70
(B) 120
(C) 720
(D) 5040
4.
(A) 90
(B) 105
ix
(C) 120
(D) 135
5.
(A) 24
(B) 26
(C) 28
(D) 30
EXPERIMENT NO. 4
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Sem ECE
Link to Code:
Date: 24/02/2021
Faculty Signature:
Marks:
1. If a file with execute permissions set, but with unknown file format is executed
a) The file is passed to /bin/sh
b) The system returns an error
c) The current shell will try to execute it
d) None of the mentioned
Answer: c
Answer: c
Answer: c
Answer: a
Answer: d
6. The user bhojas logged in and performed the following sequence of command. What will be the output of
the last command?
$ cd project/module1
$ pwd
a) /home/bhojas/project/module1
b) /home/project/module1
c) /usr/bhojas/project/module1
d) project/module1
Answer: a
Answer: a
xiii
Screenshots
xiv
EXPERIMENT NO. 5
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Sem ECE
Link to Code:
Date: 24/02/2021
Faculty Signature:
Marks:
Objective: Write a shell program to display the menu and execute instructions accordingly.
(i)List of file (ii)Process Status (iii) Date (iv) users in program (v) Quit
Outcome: Display the menu of list of file, process status, users in program and quit
Screenshots
xv
EXPERIMENT NO. 6
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Sem ECE
Link to Code:
Date: 24/02/2021
Faculty Signature:
Marks:
1. Suppose the first fibonnaci number is 0 and the second is 1. What is the sixth fibonnaci number?
a) 5
b) 6
c) 7
d) 8
Answer: a
Explanation: The sixth fibonnaci number is 5.
Answer: d
Explanation: 14 is not a fibonnaci number.
Answer: d
Explanation: Fibonacci number can be calculated by using Dynamic Programming, Recursion method,
Iteration Method.
4. Consider the following iterative implementation to find the nth fibonacci number?
int main()
{
int n = 10,i;
if(n == 1)
printf("0");
else if(n == 2)
printf("1");
else
{
int a = 0, b = 1, c;
for(i = 3; i <= n; i++)
{
c = a + b;
________;
________;
}
printf("%d",c);
}
return 0;
}
Which of the following lines should be added to complete the above code?
a)
c = b
b = a
b)
a = b
b = c
c)
b = c
a = b
d)
a = b
b = a
xviii
Answer: b
Explanation: The lines “a = b” and “b = c” should be added to complete the above code.
5. Which of the following recurrence relations can be used to find the nth fibonacci number?
a) F(n) = F(n) + F(n – 1)
b) F(n) = F(n) + F(n + 1)
c) F(n) = F(n – 1)
d) F(n) = F(n – 1) + F(n – 2)
Answer: d
Explanation: The relation F(n) = F(n – 1) + F(n – 2) can be used to find the nth fibonacci number.
6. Consider the following recursive implementation to find the nth fibonacci number:
int fibo(int n)
{
if(n == 1)
return 0;
else if(n == 2)
return 1;
return ________;
}
int main()
{
int n = 5;
int ans = fibo(n);
printf("%d",ans);
return 0;
}
Which of the following lines should be inserted to complete the above code?
a) fibo(n – 1)
b) fibo(n – 1) + fibo(n – 2)
c) fibo(n) + fibo(n – 1)
d) fibo(n – 2) + fibo(n – 1)
Answer: b
Explanation: The line fibo(n – 1) + fibo(n – 2) should be inserted to complete the above code.
7. Consider the following recursive implementation to find the nth fibonnaci number:
int fibo(int n)
{
if(n == 1)
return 0;
else if(n == 2)
return 1;
return fibo(n - 1) + fibo(n - 2);
}
int main()
{
xix
int n = 5;
int ans = fibo(n);
printf("%d",ans);
return 0;
}
Answer: d
Explanation: Both if(n == 1) and else if(n == 2) are the base cases.
Screenshots
xx
EXPERIMENT NO. 7
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Sem ECE
Link to Code:
Date: 10/02/2021
Faculty Signature:
Marks:
1) #include<userdefined.h>
Which of the following is the correct syntax to add the header file in the C++ program?
1. #include<userdefined>
2. #include "userdefined.h"
3. <include> "userdefined.h"
4. Both A and B
Answer: D
Explanation: To include the herder files in the C++ program user can use any of the following given syntax.
2) Which of the following is the correct syntax to print the message in C++ language?
Answer: A
xxii
1. $var_name
2. VAR_123
3. varname@
4. None of the above
Answer: B
1. @
2. #
3. &
4. %
Answer: C
5) Which of the following features must be supported by any programming language to become a
pure object-oriented programming language?
1. Encapsulation
2. Inheritance
3. Polymorphism
4. All of the above
Answer: D
6) The programming language that has the ability to create new data types is called___.
1. Overloaded
2. Encapsulated
3. Reprehensible
4. Extensible
Answer: D
1. Dennis Ritchie
2. Ken Thompson
3. Bjarne Stroustrup
4. Brian Kernighan
Answer: C
xxiii
Screenshots
xxiv
EXPERIMENT NO. 8
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Sem ECE
Link to Code:
Date: 10/02/2021
Faculty Signature:
Marks:
Outcome:
a) Operating solve
b) Open Source
c) Open System
d) Operating system
Answer : d
a) Worldwide corporation
b) W3C
c) World Wide Web Standard
d) World Wide Consortium
Answer : b
Q3. A co-processor
xxv
Answer : a
a) Operating system
b) Graphic program
c) Word Processing
d) Database program
Answer : a
a) Accessories
b) Paint
c) Word
d) All of above
Answer : a
a) Windows NT
b) Page Maker
c) WinWord XP
d) Photoshop
Answer : a
a) WinZip
b) WinShrink
c) WinStyle
d) None of above
Answer : a
xxvi
Screenshots
xxvii
EXPERIMENT NO. 9
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Sem ECE
Link to Code:
Date: 03/03/2021
Faculty Signature:
Marks:
Outcome: FCFS non-preemptive CPU scheduling algorithms to find turnaround time and
waiting time
Problem Statement: To simulate the FCFS non-preemptive CPU scheduling algorithms to find
turnaround time and waiting time
Background Study:
Question Bank:
Answer: b
Answer: a
Explanation: All the processes will be able to get completed.
3. The portion of the process scheduler in an operating system that dispatches processes is concerned
with ____________
a) assigning ready processes to CPU
xxviii
Answer: a
Answer: a
Explanation: Large computers are overloaded with a greater number of processes.
Answer: b
6. The strategy of making processes that are logically runnable to be temporarily suspended is called
____________
a) Non preemptive scheduling
b) Preemptive scheduling
c) Shortest job first
d) First come First served
Answer: b
7. What is Scheduling?
a) allowing a job to use the processor
b) making proper use of processor
c) all of the mentioned
d) none of the mentioned
Answer: a
xxix
#include<iostream>
#define MAX_PROCESS 10
class process
public:
int process_num;
int burst_time;
int arrival_time;
int response_time;
int waiting_time;
int turnaround_time;
void input_process(int);
int get_at()
return arrival_time;
};
process_num=count+1;
cin>>burst_time;
cin>>arrival_time;
void calc_wait_tat(process*,int);
void average(process*,int);
void display(process*,int);
int main()
process p[MAX_PROCESS],temp;
int num,i,j;
cin>>num;
for(i=0;i<num;++i)
p[i].input_process(i);
for(i=0;i<num;++i)
for(j=i+1;j<num;++j)
if(p[i].get_at()>p[j].get_at())
temp=p[i];
p[i]=p[j];
p[j]=temp;
calc_wait_tat(p,num);
display(p,num);
xxxi
return 0;
int i;
p[0].response_time=0;
for(i=1;i<n;++i)
p[i].response_time=p[i-1].burst_time+p[i-1].response_time;
if(p[i].response_time<p[i].arrival_time)
p[i].response_time=p[i].arrival_time;
p[0].waiting_time=0;
for(i=1;i<n;++i)
p[i].waiting_time=p[i].response_time-p[i].arrival_time;
for(i=0;i<n;++i)
p[i].turnaround_time=p[i].waiting_time+p[i].burst_time;
float avg_wt=0,avg_tat=0;
for(int i=0;i<n;++i)
avg_wt+=(float)p[i].waiting_time;
avg_tat+=(float)p[i].turnaround_time;
avg_wt/=n;
xxxii
avg_tat/=n;
cout<<"Processes "<<" Burst time "<<" Waiting time "<<" Turn around time\n";
average(p,n);
}
xxxiii
EXPERIMENT NO. 10
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Semester ECE
Date: 03/03/2021
Faculty Signature:
Marks:
Objective: Write a C program to simulate the SJF non-preemptive CPU scheduling algorithms to
find turnaround time and waiting time
Outcome: SJF non-preemptive CPU scheduling algorithms to find turnaround time and waiting time
Problem Statement: To simulate SJF non-preemptive CPU scheduling algorithms to find
turnaround time and waiting time
Background Study: SJF non primitive
Question Bank:
Answer: b
Answer: b
Answer: b
Explanation: In a time sharing system, each user needs to get a share of the CPU at regular intervals.
4. Consider the following set of processes, the length of the CPU burst time given in milliseconds.
Assuming the above process being scheduled with the SJF scheduling algorithm.
a) The waiting time for process P1 is 3ms
b) The waiting time for process P1 is 0ms
c) The waiting time for process P1 is 16ms
d) The waiting time for process P1 is 9ms
Answer: a
Answer: d
Answer: a
Explanation: The larger the CPU burst, the lower the priority.
Answer: c
xxxv
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string.h>
using namespace std;
struct process {
int pid;
int arrival_time;
int burst_time;
int start_time;
int completion_time;
int turnaround_time;
int waiting_time;
int response_time;
};
int main() {
int n;
struct process p[100];
float avg_turnaround_time;
float avg_waiting_time;
float avg_response_time;
float cpu_utilisation;
int total_turnaround_time = 0;
int total_waiting_time = 0;
int total_response_time = 0;
int total_idle_time = 0;
float throughput;
int is_completed[100];
memset(is_completed,0,sizeof(is_completed));
p[i].pid = i+1;
cout<<endl;
}
int current_time = 0;
int completed = 0;
int prev = 0;
while(completed != n) {
int idx = -1;
int mn = 10000000;
for(int i = 0; i < n; i++) {
if(p[i].arrival_time <= current_time && is_completed[i] == 0) {
if(p[i].burst_time < mn) {
mn = p[i].burst_time;
idx = i;
}
if(p[i].burst_time == mn) {
if(p[i].arrival_time < p[idx].arrival_time) {
mn = p[i].burst_time;
idx = i;
}
}
}
}
if(idx != -1) {
p[idx].start_time = current_time;
p[idx].completion_time = p[idx].start_time + p[idx].burst_time;
p[idx].turnaround_time = p[idx].completion_time - p[idx].arrival_time;
p[idx].waiting_time = p[idx].turnaround_time - p[idx].burst_time;
p[idx].response_time = p[idx].start_time - p[idx].arrival_time;
total_turnaround_time += p[idx].turnaround_time;
total_waiting_time += p[idx].waiting_time;
total_response_time += p[idx].response_time;
total_idle_time += p[idx].start_time - prev;
is_completed[idx] = 1;
completed++;
current_time = p[idx].completion_time;
prev = current_time;
}
else {
current_time++;
}
}
xxxvii
cout<<endl<<endl;
cout<<"#P\t"<<"AT\t"<<"BT\t"<<"ST\t"<<"CT\t"<<"TAT\t"<<"WT\t"<<"RT\t"<<"\n"<<endl;
cout<<p[i].pid<<"\t"<<p[i].arrival_time<<"\t"<<p[i].burst_time<<"\t"<<p[i].start_time<<"\t"<<
p[i].completion_time<<"\t"<<p[i].turnaround_time<<"\t"<<p[i].waiting_time<<"\t"<<p[i].respo
nse_time<<"\t"<<"\n"<<endl;
}
cout<<"Average Turnaround Time = "<<avg_turnaround_time<<endl;
cout<<"Average Waiting Time = "<<avg_waiting_time<<endl;
cout<<"Average Response Time = "<<avg_response_time<<endl;
cout<<"CPU Utilization = "<<cpu_utilisation<<"%"<<endl;
cout<<"Throughput = "<<throughput<<" process/unit time"<<endl;
}
xxxviii
EXPERIMENT NO. 11
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Semester ECE
Date: 03/03/2021
Faculty Signature:
Marks:
Objective: Write a C++ program to simulate the SJRF preemptive CPU scheduling algorithms to
find turnaround time
Outcome: SRJF preemptive CPU scheduling algorithms to find turnaround time and waiting time
Problem Statement: To simulate SRJF preemptive CPU scheduling algorithms to find turnaround
time and waiting time
Background Study:
Question Bank:
Question 1 : Which of the following scheduling algorithms gives minimum average waiting time ?
1. FCFS
2. SJF
3. Round – robin
4. Priority
Answer : Option 2 - SJF
#include <bits/stdc++.h>
struct Process {
};
// processes
int wt[])
int rt[n];
rt[i] = proc[i].bt;
// completed
while (complete != n) {
// current time`
minm = rt[j];
shortest = j;
check = true;
if (check == false) {
t++;
continue;
rt[shortest]--;
// Update minimum
minm = rt[shortest];
if (minm == 0)
minm = INT_MAX;
// executed
if (rt[shortest] == 0) {
// Increment complete
complete++;
check = false;
// process
finish_time = t + 1;
wt[shortest] = finish_time -
proc[shortest].bt -
proc[shortest].art;
if (wt[shortest] < 0)
wt[shortest] = 0;
// Increment time
t++;
// bt[i] + wt[i]
total_tat = 0;
// processes
findWaitingTime(proc, n, wt);
// all processes
// details
xlv
// Driver code
int main()
Process proc[] = { { 1, 6, 1 }, { 2, 8, 1 },
xlvi
{ 3, 7, 2 }, { 4, 3, 3 } };
findavgTime(proc, n);
return 0;
}
xlvii
EXPERIMENT NO. 12
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Semester ECE
Date: 31/03/2021
Faculty Signature:
Marks:
Objective: Write a C++ program to simulate the Round Robin CPU scheduling algorithms to
find turnaround time and waiting time.
Outcome: Round Robin CPU scheduling algorithms to find turnaround time and waiting time
Problem Statement: To simulate the Round Robin CPU scheduling algorithms to find
turnaround time and waiting time
Background Study: Round robin function
Question Bank:
Answer: b
Answer: a
Explanation: All the processes will be able to get completed.
3. The portion of the process scheduler in an operating system that dispatches processes is concerned
with ____________
a) assigning ready processes to CPU
b) assigning ready processes to waiting queue
c) assigning running processes to blocked queue
xlviii
Answer: a
Explanation: Large computers are overloaded with a greater number of processes.
5. The strategy of making processes that are logically runnable to be temporarily suspended is called
____________
a) Non preemptive scheduling
b) Preemptive scheduling
c) Shortest job first
d) First come First served
Answer: b
6. What is Scheduling?
a) allowing a job to use the processor
b) making proper use of processor
c) all of the mentioned
d) none of the mentioned
Answer: a
7. There are 10 different processes running on a workstation. Idle processes are waiting for an input
event in the input queue. Busy processes are scheduled with the Round-Robin time sharing method.
Which out of the following quantum times is the best value for small response times, if the processes
have a short runtime, e.g. less than 10ms?
a) tQ = 15ms
b) tQ = 40ms
c) tQ = 45ms
d) tQ = 50ms
View Answer
Answer: a
#include<iostream>
#include<cstdlib>
#include<queue>
#include<cstdio>
int id,at,bt,st,ft,pr;
float wt,tat;
}process;
process p[10],p1[10],temp;
queue<int> q1;
int main()
int i,n,ts,ch,j,x;
p[0].tat=0;
p[0].wt=0;
n=accept(ch);
ganttrr(n);
l
turnwait(n);
display(n);
return 0;
int i,n;
scanf("%d",&n);
if(n==0)
printf("Invalid");
exit(1);
cout<<endl;
for(i=1;i<=n;i++)
scanf("%d",&p[i].at);
p[i].id=i;
cout<<endl;
for(i=1;i<=n;i++)
li
scanf("%d",&p[i].bt);
for(i=1;i<=n;i++)
p1[i]=p[i];
return n;
void ganttrr(int n)
nextval=p1[1].at;
i=1;
cin>>ts;
q1.push(p1[i].id);
while(!q1.empty())
m=q1.front();
q1.pop();
lii
if(p1[m].bt>=ts)
nextval=nextval+ts;
else
nextval=nextval+p1[m].bt;
if(p1[m].bt>=ts)
p1[m].bt=p1[m].bt-ts;
else
p1[m].bt=0;
while(i<=n&&p1[i].at<=nextval)
q1.push(p1[i].id);
i++;
if(p1[m].bt>0)
q1.push(m);
liii
if(p1[m].bt<=0)
p[m].ft=nextval;
void turnwait(int n)
int i;
for(i=1;i<=n;i++)
p[i].tat=p[i].ft-p[i].at;
p[i].wt=p[i].tat-p[i].bt;
p[0].tat=p[0].tat+p[i].tat;
p[0].wt=p[0].wt+p[i].wt;
p[0].tat=p[0].tat/n;
p[0].wt=p[0].wt/n;
void display(int n)
int i;
/*
Here
liv
at = Arrival time,
bt = Burst time,
wt = Waiting time
*/
cout<<"\n=====================================================\n";
cout<<"\n===================TABLE==============================\n";
printf("\nProcess\tAT\tBT\tFT\tTAT\t\tWT");
for(i=1;i<=n;i++)
printf("\nP%d\t%d\t%d\t%d\t%f\t%f",p[i].id,p[i].at,p[i].bt,p[i].ft,p[i].tat,p[i].wt);
cout<<"\n=====================================================\n";
}
lv
EXPERIMENT NO. 13
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Semester ECE
Date: 07/04/2021
Faculty Signature:
Marks:
Objective: Write a C++ program to simulate the Priority non- preemptive CPU scheduling
algorithms to find turnaround time and waiting time.
Outcome: Priority non--preemptive CPU scheduling algorithms to find turnaround and waiting time.
Problem Statement: To simulate Priority non--preemptive CPU scheduling algorithms to find
turnaround and waiting time.
Background Study:
Question Bank:
Explanation: Priority scheduling is a non-preemptive algorithm and one of the most common
scheduling algorithms in batch systems.
7. At the ready queue when a process arrives In priority scheduling algorithm, the priority of this
process is compared with the priority of?
A. currently running process
B. parent process
C. all process
D. init process
Answer: A
#include<iostream>
lviii
int main()
int a[10],b[10],x[10],pr[10]={0};
int waiting[10],turnaround[10],completion[10];
int i,j,smallest,count=0,time,n;
double avg=0,tt=0,end;
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<n;i++)
cin>>pr[i];
for(i=0;i<n;i++)
lix
x[i]=b[i];
pr[9]=-1;
for(time=0;count!=n;time++)
smallest=9;
for(i=0;i<n;i++)
smallest=i;
time+=b[smallest]-1;
b[smallest]=-1;
count++;
end=time+1;
completion[smallest] = end;
for(i=0;i<n;i++)
cout<<"p"<<i+1<<"\t\t"<<x[i]<<"\t\t"<<a[i]<<"\t\t"<<waiting[i]<<"\t\t"<<turnaround[i]<<"\t\t"
<<completion[i]<<"\t\t"<<pr[i]<<endl;
lx
tt = tt + turnaround[i];
}
lxi
EXPERIMENT NO. 14
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Semester ECE
Date: 10/04/2021
Faculty Signature:
Marks:
Objective: Write a C++ program to simulate the Priority preemptive CPU scheduling algorithms to
find turnaround time and waiting time
Outcome: Priority preemptive CPU scheduling algorithms to find turnaround time and waiting time.
Problem Statement: To simulate the Priority preemptive CPU scheduling algorithms to find
turnaround time and waiting time
Background Study: Priority scheduling
Question Bank:
Ans : B
Explanation: Processes with same priority are executed on first come first served basis.
2. At the ready queue when a process arrives In priority scheduling algorithm, the priority of this
process is compared with the priority of?
A. currently running process
B. parent process
C. all process
D. init process
Answer: A
Answer:C
4. scheduling algorithm which allocates the CPU first to the process which requests the CPU first?
A. FCFS scheduling
B. priority scheduling
C. shortest job scheduling
D. none of the mentioned
Answer: A
5. In an operating system, the portion of the process scheduler that forward processes is concerned
with :
A. running processes are assigning to blocked queue
B. ready processes are assigning to CPU
C. ready processes are assigning to the waiting queue
D. all of the mentioned
Answer: B
6. From the time of submission of a process to the time of completion, The interval is termed as
A. waiting time
B. turnaround time
C. response time
D. throughput
Answer: B
7. From the time of submission of a process to the time of completion, The interval is termed as
A. waiting time
B. turnaround time
C. response time
D. throughput
Answer: B
#include<iostream>
int main()
int a[10],b[10],x[10];
int waiting[10],turnaround[10],completion[10],p[10];
int i,j,smallest,count=0,time,n;
double avg=0,tt=0,end;
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<n;i++)
cin>>p[i];
x[i]=b[i];
lxiv
p[9]=-1;
smallest=9;
smallest=i;
b[smallest]--;
if(b[smallest]==0)
count++;
end=time+1;
completion[smallest] = end;
cout<<"p"<<i+1<<"\t\t"<<x[i]<<"\t\t"<<a[i]<<"\t\t"<<waiting[i]<<"\t\t"<<turnaround[i]<<"\t\t"
<<completion[i]<<"\t\t"<<p[i]<<endl;
lxv
tt = tt + turnaround[i];
}
lxvi
EXPERIMENT NO. 15
Student Name and Roll Number: Parth Bathla (18ecu016)
Semester /Section: 6th Semester ECE
Date: 05/05/2021
Faculty Signature:
Marks:
Objective: Write a C++ program to simulate Bankers algorithm for the purpose of deadlock
avoidance.
Problem Statement: To simulate Bankers algorithm for the purpose of deadlock avoidance.
Background Study: Bankers problem using deadlock situation
Question Bank:
1. Each request requires that the system consider the _____________ to decide whether the current
request can be satisfied or must wait to avoid a future possible deadlock.
a) resources currently available
b) processes that have previously been in the system
c) resources currently allocated to each process
d) future requests and releases of each process
Answer: a
2. Given a priori information about the ________ number of resources of each type that maybe
requested for each process, it is possible to construct an algorithm that ensures that the system will
never enter a deadlock state.
a) minimum
b) average
c) maximum
d) approximate
Answer: c
3. A deadlock avoidance algorithm dynamically examines the __________ to ensure that a circular
wait condition can never exist.
a) resource allocation state
b) system storage state
lxvii
c) operating system
d) resources
Answer: a
Explanation: Resource allocation states are used to maintain the availability of the already and
current available resources.
Answer: b.
Answer: c
Answer: b
Answer: b
lxviii
#include<stdio.h>
#include<conio.h>
int main() {
int
k=0,output[10],d=0,t=0,ins[5],i,avail[5],allocated[10][5],need[10][5],MAX[10][5],pno,P[10],j,rz
, count=0;
scanf("%d", &rz);
for (i=0;i<rz;i++) {
avail[i]=0;
printf("%c= ",(i+97));
scanf("%d",&ins[i]);
scanf("%d", &pno);
for (i=0;i<rz;i++)
printf(" %c",(i+97));
printf("\n");
P[i]=i;
printf("P[%d] ",P[i]);
for (j=0;j<rz;j++) {
lxix
scanf("%d",&allocated[i][j]);
avail[j]+=allocated[i][j];
for (i=0;i<rz;i++) {
printf(" %c",(i+97));
avail[i]=ins[i]-avail[i];
printf("\n");
printf("P[%d] ",i);
for (j=0;j<rz;j++)
scanf("%d", &MAX[i][j]);
printf("\n");
A: d=-1;
count=0;
t=P[i];
for (j=0;j<rz;j++) {
need[t][j] = MAX[t][j]-allocated[t][j];
if(need[t][j]<=avail[j])
count++;
}
lxx
if(count==rz) {
output[k++]=P[i];
for (j=0;j<rz;j++)
avail[j]+=allocated[t][j];
} else
P[++d]=P[i];
if(d!=-1) {
pno=d+1;
goto A;
printf("\t <");
for (i=0;i<k;i++)
printf(">");
getch();
}
lxxi