Operating System Lab Manual
Operating System Lab Manual
(KCS-451)
Laboratory Manual
For
Bachelor of Technology
In
Computer Science and Engineering
IV Semester
List of Practical’s
1. Study of hardware and software requirements of different operating systems (UNIX, LINUX, WINDOWS XP,
WINDOWS7/8)
2. Execute various UNIX system calls for i. Process management ii. File management iii. Input/output Systems calls
3. Implement CPU Scheduling Policies: i. SJF ii. Priority iii. FCFS iv. Multi-level Queue
4. Implement file storage allocation technique: i. Contiguous (using array) ii. Linked –list(using linked-list) iii. Indirect
allocation (indexing)
5. Implementation of contiguous allocation techniques: i. Worst-Fit ii. Best- Fit iii. First- Fit
6. Calculation of external and internal fragmentation i. Free space list of blocks from system ii. List process file from
the system
7. Implementation of compaction for the continually changing memory layout and calculate total movement of data
8. Implementation of resource allocation graph RAG)
9. Implementation of Banker‟s algorithm
10. Conversion of resource allocation graph (RAG) to wait for graph (WFG) for each type of method used for storing
graph.
11. Implement the solution for Bounded Buffer (producer-consumer) problem using inter process communication
Techniques-Semaphores
12. Implement the solutions for Readers-Writers problem using inter process communication technique –Semaphore
Vision of Institute
Be known globally for value-added Education Innovation Research at the intersection of
disciplines in service of humankind.
Mission of Institute
➢ Place a multidisciplinary engineering education ecosystem that transforms learners into future innovators,
entrepreneurs, and professional leaders.
➢ Create an ambiance of interdisciplinary research, innovation, and creativity to address regional and global
challenges for benefit of human life and the environment.
➢ Provide the environment for enhancing knowledge, and inculcating critical & design thinking, life skills
through quality learning Systems.
➢ Collaborate with globally renowned academic & research institutions and corporate for improving
productivity and economics.
DEPARTMENT VISION AND MISSION
Vision of the Department
To produce computer science and engineering graduates with problem solving abilities,
research aptitude, teamwork, and ethical values to meet the needs of industry and society.
✓ To prepare students with strong technical skills and analytical minds for real time
industrial needs.
✓ To nurture the students to contribute in research and innovation for nation building.
services to society.
PROGRAMME OUTCOMES
Program Statement
Outcom
e
PO1 Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and
an engineering specialization to the solution of complex computer engineering problems.
PO2 Problem analysis: Identify, formulate, review research literature, and analyze complex computer
engineering problems reaching substantiated conclusions using first principles of mathematics, natural
sciences, and engineering sciences.
PO3 Design/development of solutions: Design solutions for complex computer engineering problems and
design system components or processes that meet the specific needs with appropriate considerations for
the public health and safety, and the cultural, societal, and environmental considerations.
PO4 Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
provide conclusions
PO5 Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering
and IT tools including prediction and modeling to complex engineering activities with an understanding
of the limitations
PO6 The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent relevant to the professional engineering
practices
PO7 Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development
PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norm of the
engineering practices
PO9 Individual and team work: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings
PO10 Communications: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions
PO11 Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.
PO12 Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life learning in the broadest context of technological change.
On completion of the B.Tech (Computer Science & Engineering), the graduates will be able to
PSO-3: Successful Career and Entrepreneurship: will be able to employ the best programming
skills, environments, and platforms, to identify and build innovative career options, and
enthusiasm for higher studies.
Blooms
CO Course outcomes
Level
Design and implement various Non Pre-emptive CPU scheduling
CO1 BL6
Algorithm's.
CO2 Design and implement various Pre-emptive CPU scheduling Algorithm's. BL6
CO3 Apply various deadlock policies & memory management concepts and BL3
CO5 Apply Disk scheduling algorithms and analyze the performance. BL3
CO – PO / PSO Mapping
CO PO1 PO PO PO PO PO PO PO8 PO PO1 PO1 PO1 PSO PSO PSO
2 3 4 5 6 7 9 0 1 2 1 2 3
CO1 2 3 1 1 2 2 2 1 1
CO2 3 2 2 3 2 2 2 2 2
CO3 3 2 2 3 2 2 2 2 2
CO4 3 2 2 3 2 2 2 2 2
CO5 3 2 2 3 2 2 2 2 2
Averag 1.80
2.80 2.20 1.80 2.60 2.00 2.00 2.00 1.80
e
Experiment 1: Study of hardware and software requirements of different operating systems (UNIX, LINUX,
WINDOWS XP, WINDOWS7/8)
Objective: to make familiar with hardware and software requirements for the different types of operating
systems.
Steps to be followed
UNIX:
Hardware Requirements:
Minimum of 64MB of RAM
Minimum of 500MB of free hard disk space
Pentium-compatible processor
Software Requirements:
UNIX:
Hardware Requirements:
64MB of RAM is the minimum requirement, but a larger amount of memory is recommended for better
performance. Some UNIX distributions recommend 256MB or more.
500MB of free hard disk space is the minimum requirement, but again, more is recommended depending on
the intended use case.
A Pentium-compatible processor is usually sufficient, but some UNIX distributions may have specific
processor requirements.
Software Requirements:
The UNIX kernel is the core of the operating system and provides the basic functionality for all other
software to run on top of.
The command line interface (CLI) is the primary way to interact with the system, using text-based commands
to perform tasks like navigating the file system, launching applications, and managing users and permissions.
LINUX:
Hardware Requirements:
Most modern Linux distributions recommend at least 512MB of RAM, but some distributions may require
more depending on the intended use case.
20GB of free hard disk space is recommended, but again, this can vary depending on the intended use case.
Windows 10/11
Hardware Requirements:
Processor: 1 gigahertz (GHz) or faster processor or System on a Chip (SoC)
RAM: 4 gigabytes (GB) or greater
Storage: 64 GB or greater storage device (such as a hard drive or solid state drive (SSD))
Graphics Card: DirectX 12 compatible graphics / WDDM 2.x
Display: 720p or greater resolution display
Internet connection: Internet connectivity is necessary to perform updates and to download and
take advantage of some features.
Software Requirements:
Windows 10/11 is a complete operating system that includes a graphical user interface
and support for a wide range of hardware and software applications.
The operating system includes the latest version of the Windows kernel, which provides
the basic functionality for all other software to run on top of.
Windows 10/11 includes Microsoft Edge as the default web browser.
DirectX 12 is included in Windows 10/11, which provides support for advanced graphics
applications and games.
Objective : To make familiar with unix system calls for the process, file and input output management.
Steps to be followed:
We will use online linux compiler : onecompiler.com
Program: Use of fork system call
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
fork();
printf("Using fork() system call\n");
return 0;
}
Output:
int main()
{
int p=getpid();
fork();
printf("Using fork() system call\n");
printf( "the process id is : %d", p);
return 0;
}
Output:
Using fork() system call
the process id is : 7943Using fork() system call
the process id is : 7943
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
char p[10][5];
int tot=0,wt[10],i,n;
float avg=0;
clrscr();
printf("enter no of processes:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter process%d name:\n",i+1);
scanf("%s",&p[i]);
printf("enter process time");
scanf("%d",&pt[i]);
}
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=wt[i-1]+et[i-1];
tot=tot+wt[i];
}
avg=(float)tot/n;
printf("p_name\t P_time\t w_time \n");
for(i=0;i<n;i++)
printf("%s\t%d\t%d\n",p[i],et[i],wt[i]);
printf("total waiting time=%d\n avg waiting time=%f",tot,avg);
getch();
}
Program Output:
enter no of processes: 5
enter process1 name: aaa
enter process time: 4
enter process2 name: bbb
enter process time: 3
enter process3 name: ccc
enter process time: 2
enter process4 name: ddd
enter process time: 5
enter process5 name: eee
enter process time: 1
p_name P_time w_time
aaa 4 0
bbb 3 4
ccc 2 7
ddd 5 9
Experiment-4
Program Prerequisite:- Basic knowledge of C programming and Concept of related Operating system algorithm
Program Code:-
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
char p[10][5],temp[5];
int tot=0,wt[10],pt[10],i,j,n,temp1;
float avg=0;
clrscr();
printf("enter no of processes:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter process%d name:\n",i+1);
scanf("%s",&p[i]);
printf("enter process time");
scanf("%d",&pt[i]);
}
eee 1 0
ccc 2 1
bbb 3 3
aaa 4 6
ddd 5 10
total waiting time=20
avg waiting time=4.00
b[9]=9999;
for(time=0;count!=n;time++)
{
smallest=9;
for(i=0;i<n;i++)
{
if(a[i]<=time && b[i]<b[smallest] && b[i]>0 )
smallest=i;
}
b[smallest]--;
if(b[smallest]==0)
{
count++;
end=time+1;
avg=avg+end-a[smallest]-x[smallest];
tt= tt+end-a[smallest];
}
}
Program Output:-
Enter the number of Processes:
4
enter arrival time
0
1
2
3
enter burst time
8
4
9
5
Average waiting time = 6.500000
Average Turnaround time = 13.000000
Experiment-6
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter process%d name:",i+1);
scanf("%s",&p[i]);
printf("enter process time:");
scanf("%d",&pt[i]);
printf("enter priority:");
scanf("%d",&pr[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(pr[i]>pr[j])
{
temp1=pr[i];
pr[i]=pr[j];
pr[j]=temp1;
temp1=pt[i];
pt[i]=pt[j];
pt[j]=temp1;
strcpy(temp,p[i]);
strcpy(p[i],p[j]);
strcpy(p[j],temp);
}
}
}
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=wt[i-1]+et[i-1];
totwt=totwt+wt[i];
}
avgwt=(float)totwt/n;
printf("p_name\tp_time\t priority\tw_time\n");
for(i=0;i<n;i++)
{
printf(" %s\t %d\t %d\t %d\n" ,p[i],pt[i],pr[i],wt[i]);
}
printf("total waiting time=%d\navg waiting time=%f",tot,avg);
getch();
}
Experiment -7
count=0;
for(i=0;i<m;i++)
{
for(j=i+1;j<=n;j++)
{
if(strcmp(p[i],p[j])==0)
{
count++;
found=j;
}
}
if(found!=0)
{
wt[i]=wt[found]-(count*timer);
count=0;
found=0;
}
}
for(i=0;i<m;i++)
{
totwt+=wt[i];
}
avgwt=(float)totwt/m;
for(i=0;i<m;i++)
{
printf("\n%s\t%d\t%d",p[i],pt[i],wt[i]);
}
printf("\ntotal waiting time %d\n",totwt);
printf("total avgtime %f",avgwt);
Program Output :
enter the process name : aaa
enter the processing time : 4
enter the process name : bbb
enter the processing time : 3
enter the process name : ccc
enter the processing time : 2
enter the process name : ddd
enter the processing time : 5
enter the process name : eee
enter the processing time : 1
Program Prerequisite:- Basic knowledge of C programming and Concept of related Operating system algorithm
Program Code:
/*Write a C program to simulate multi-level queue scheduling algorithm considering the
following scenario. All the processes in the system are divided into two categories -
system processes and user processes. System processes are to be given higher priority
than user processes. The priority of each process ranges from 1 to 3.
Use fixed priority scheduling for all the processes.*/
#include<stdio.h>
#include<stdlib.h>
main()
{
int p[30],bt[30], su[30], wt[30],tat[30],i, k, n, temp;
float waiting_avg, turnaround_avg;
int tr;
int csource=0;
int cuser=0;
int btsource[30],btuser[30],puser[30],psource[30];
printf("Enter the number of processes : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("System process/User Process (0/1) : ");
scanf("%d", &tr);
printf("Enter the Burst Time of Process %d : ", i);
if(tr==1){
scanf("%d",&btuser[cuser]);
puser[cuser]=i;
cuser++;
}
else if(tr==0){
scanf("%d",&btsource[csource]);
psource[csource]=i;
csource++;
}
}
for(i=0;i<csource;i++){
p[i]=psource[i];
bt[i]=btsource[i];
su[i]=0;
}
waiting_avg = wt[0] = 0;
turnaround_avg = tat[0] = bt[0];
for(i=1;i<n;i++)
{
wt[i] = wt[i-1] + bt[i-1];
tat[i] = tat[i-1] + bt[i];
waiting_avg = waiting_avg + wt[i];
turnaround_avg = turnaround_avg + tat[i];
}
printf("\nPROCESS\t SYSTEM/USER PROCESS \tBURST TIME\tWAITING TIME\tTURNAROUND TIME");
for(i=0;i<n;i++)
printf("\n%d \t\t %d \t\t %d \t\t %d \t\t %d ",p[i],su[i],bt[i],wt[i],tat[i]);
printf("\nAverage Waiting Time is : %f",waiting_avg/n);
printf("\nAverage Turnaround Time is :%f\n",turnaround_avg/n);
}
Output
/tmp/V1OrAZNYcG.o
Enter the number of processes : 5
System process/User Process (0/1) : 0
Enter the Burst Time of Process 0 : 5
System process/User Process (0/1) : 0
Enter the Burst Time of Process 1 : 3
System process/User Process (0/1) : 1
Enter the Burst Time of Process 2 : 8
System process/User Process (0/1) : 1
Enter the Burst Time of Process 3 : 4
System process/User Process (0/1) : 1
Enter the Burst Time of Process 4 : 5
0513283445
PROCESS SYSTEM/USER PROCESS BURST TIME WAITING TIME TURNAROUND TIME
0 0 5 0 5
1 0 3 5 8
2 1 8 8 16
3 1 4 16 20
4 1 5 20 25
Average Waiting Time is : 9.800000
Average Turnaround Time is :14.800000
Experiment-9
Program Prerequisite:- Basic knowledge of C programming and Concept of related Operating system algorithm
#include<stdio.h>
#include<conio.h>
intfr[3];
void main()
{
void display();
inti,j,page[12]={2,3,2,1,5,2,4,5,3,2,5,2};
int flag1=0,flag2=0,pf=0,frsize=3,top=0;
clrscr();
for(i=0;i<3;i++)
{
fr[i]=-1;
}
for(j=0;j<12;j++)
{
flag1=0;
flag2=0;
for(i=0;i<12;i++)
{
if(fr[i]==page[j])
{
flag1=1;
flag2=1;
break;
}
}
if(flag1==0)
{
for(i=0;i<frsize;i++)
{
if(fr[i]==-1)
{
fr[i]=page[j];
flag2=1;
break;
}
}
}
if(flag2==0)
{
fr[top]=page[j];
top++;
pf++;
if(top>=frsize)
top=0;
}
display();
}
printf("Number of page faults : %d ",pf);
getch();
}
Program Output :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
5 3 1
5 2 1
5 2 4
5 2 4
3 2 4
3 2 4
3 5 4
3 5 2
Experiment -10
Program Prerequisite:- Basic knowledge of C programming and Concept of related Operating system algorithm
Program Code:-
#include<stdio.h>
#include<conio.h>
intfr[3];
void main()
{
void display();
int p[12]={2,3,2,1,5,2,4,5,3,2,5,2},i,j,fs[3];
intindex,k,l,flag1=0,flag2=0,pf=0,frsize=3;
Program Output :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
2 5 1
2 5 1
2 5 4
2 5 4
3 5 4
3 5 2
3 5 2
3 5 2
no of page faults : 4
Program Prerequisite:- Basic knowledge of C programming and Concept of related Operating system algorithm
Program Code:-
#include<stdio.h>
#include<conio.h>
int main()
{
int page[10], pagetab[10], pframe[2][2], I,j;
int size, msize, cnt, t,k,pos,logadd,m=0;
intframeno;
long int l;
int i;
printf("\nEnter the memory size:");
scanf("%d", &msize);
printf("Enter the pase size:");
scanf("%d", &size);
cnt=(msize/size);
printf("\nEnter the logical page: ");
for(j=0;j
{
scanf("%d", &lpage[j]);
}
t=0;
k=0;
for(j=0;j
{
printf("\n");
if(t
{
printf("%d value is %d\n", t,lpage[j]);
t++;
}
else
{
t=0;
printf("%d value is %d\n", t,lpage[j]);
t++;
}
}
printf("\nEnter the page table value: ");
for(i=0;i
{
scanf("%d", &pagetab[i]);
}
printf("\nEnter the logical address: ");
scanf("%d", &logadd);
for(k=0;k
{
if(logadd==lpage[k])
{
pos=(k/size);
m=k%size;
Program Output:
Enter the memory size:4
Enter the page size:2
Enter the logical page: 2
3
4
5
0 value is 2
1 value is 3
0 value is 4
1 value is 5
Enter the page table value: 101
102
Enter the logical address: 5
Page number : 1
The frame number is 102
The corresponding physical address is 205
Experiment 12
Objective :Calculation of external and internal fragmentation i. Free space list of blocks from system ii. List
process file from the system
ALGORITHM:
Step 2: Get the memory capacity and number of processes. Step 3: Get the memory required for each process.
Step 4: If the needed memory is available for the particular process it will be allocated and the remaining memory
availability will be calculated.
Step 5: If not it has to tell no further memory remaining and the process will not be allocated with memory.
SOURCE CODE:
#include<stdio.h> #include<conio.h> void main()
{
int m=0,m1=0,m2=0,p,count=0,i; clrscr();
printf("enter the memory capacity:"); scanf("%d",&m); printf("enter the no of processes:"); scanf("%d",&p);
for(i=0;i<p;i++)
{
printf("\nenter memory req for process%d: ",i+1); scanf("%d",&m1); count=count+m1;
if(m1<=m)
{
if(count==m)
printf("there is no further memory remaining:");
printf("the memory allocated for process%d is: %d ",i+1,m);m2=m-m1; printf("\nremaining memory is: %d",m2);
m=m2;
}
}
else
{
printf("memory is not allocated for process%d",i+1);
}
printf("\nexternal fragmentation for this process is:%d",m2);
}
getch();
}
ALGORITHM:
Step 3: calculate the number of partitions the total memory has to be divided.
Step 4: Get the required memory for each process if the required memory is available in that particular partition the
process will be allocated to that partition and the internal fragmentation will be calculated.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
int main()
{
int m,p,s,p1;
int m1[4],i,f,f1=0,f2=0,fra1,fra2,s1,pos; clrscr();
printf("Enter the memory size:");
scanf("%d",&m);
printf("Enter the no of partitions:");
scanf("%d",&p); s=m/p;
printf("Each partn size is:%d",s);
printf("\nEnter the no of processes:");
scanf("%d",&p1); pos=m;
for(i=0;i<p1;i++)
{
if(pos<s)
{
printf("\nThere is no further memory for process%d",i+1); m1[i]=0; break;
}
else
{
printf("\nEnter the memory req for process%d:",i+1); scanf("%d",&m1[i]); if(m1[i]<=s)
{
printf("\nProcess is allocated in partition%d",i+1); fra1=s-m1[i]; printf("\nInternal fragmentation for process is:
%d",fra1); f1=f1+fra1; pos=pos-s;
}
else
{
printf("\nProcess not allocated in partition%d",i+1); s1=m1[i]; while(s1>s)
{
s1=s1-s;pos=pos-s;
}
pos=pos-s;fra2=s-s1;f2=f2+fra2;
printf("\nExternal Fragmentation for this process is:%d",fra2);
}
}
}
printf("\nProcess\tallocatedmemory");
for(i=0;i<p1;i++)
printf("\n%5d\t%5d",i+1,m1[i]);
f=f1+f2;
printf("\nThe tot no of fragmentation is:%d",f); getch(); return 0;
}
a). Randomly select a location from available location s1= random(100); b). Check
whether the required locations are free from the selected location. c). Allocate and set
SOURCE CODE:
#include<stdio.h>
main()
{
int f[50],i,st,j,len,c,k;
clrscr(); for(i=0;i<50;i+
+) f[i]=0;
X:
printf("\n Enter the starting block & length of file");
scanf("%d%d",&st,&len);
for(j=st;j<(st+len);j++)
if(f[j]==0)
{ f[j]=1
;
printf("\n%d->%d",j,f[j]);
}
else
{
printf("Block already allocated"); break;
}
if(j==(st+len))
printf("\n the file is allocated to disk");
printf("\n if u want to enter more files?(y-1/n-0)");
scanf("%d",&c);
if(c==1)
goto X;
else
exit();
getch();
Output:
Enter the starting block & length of file 4 10
4->1
5->1
6->1
7->1
8->1
9->1
10->1
11->1
12->1
13->1
The file is allocated to disk
If you want to enter more files? (Y-1/N-0)
To write a C program to implement File Allocation concept using the technique Linked List Technique.
ALGORITHM:
Step 5: If the location is free allocate and set flag =1 to the allocated locations. Step 6: Print
OBJECTIVE:
To write a C program to implement File Allocation concept using the technique indexed allocation
Technique
ALGORITHM:
Step 4: Allocate the required locations by selecting a location randomly. Step 5: Print
#include<stdio.h>
int f[50],i,k,j,inde[50],n,c,count=0,p; main()
{
clrscr();
for(i=0;i<50;i++)
f[i]=0;
x:
printf("enter index block\t");
scanf("%d",&p);
if(f[p]==0)
{ f[p]=1
;
printf("enter no of files on index\t");
scanf("%d",&n);
}
else
{
printf("Block already allocated\n"); goto
x;
}
for(i=0;i<n;i++)
scanf("%d",&inde[i]);
for(i=0;i<n;i++)
if(f[inde[i]]==1)
{
printf("Block already allocated"); goto
x;
}
for(j=0;j<n;j++)
f[inde[j]]=1; printf("\n
allocated");
printf("\n file indexed");
for(k=0;k<n;k++)
printf("\n %d->%d:%d",p,inde[k],f[inde[k]]); printf(" Enter 1
to enter more files and 0 to exit\t"); scanf("%d",&c);
if(c==1)
goto x;
else
exit();
getch();
OUTPUT:
OBJECTIVE:
Step 6: If the new request comes then check that the system is in safety or not if we allow the request.
#include<stdio..h>
#include<conio h>
void main()
{
int n,r,i,j,k,p,u=0,s=0,m;
int block[10],run[10],active[10],newreq[10];
int max[10][10],resalloc[10][10],resreq[10][1]; int totalloc[10],totext[10],simalloc[10];
clrscr();
printf("Enter the no of processes:"); scanf("%d",&n);
printf("Enter the no of resource classes:"); scanf("%d",&r);
printf("Enter the total existed resource in each class:"); for(k=1;k<=r;k++)
scanf("%d",&totext[k]);
printf("Enter the allocated resources:");
for(i=1;i<=n;i++)
for(k=1;k<=r;k++)
scanf("%d",&resallc);
printf("Enter the process making the new request:");
scanf("%d",&p);
printf("Enter the requested resource:");
for(k=1;k<=r;k++) scanf("%d",&newreq[k]);
printf("Enter the process which are n blocked or running:");
for(i=1;i<=n;i++)
{
if(i!=p)
{
printf("process %d:\n",i+1); scanf("%d%d",&block[i],&run[i]);
}}
block[p]=0; run[p]=0; for(k=1;k<=r;k)
{ j=0;
for(i=1;i<=n;i++) { totalloc[k]=j+resalloc[i][k]; j=totalloc[k];
}}
for(i=1;i<=n;i++)
{
if(block[i]==1||run[i]==1) active[i]=1;
else active[i]=0;
}
for(k=1;k<=r;k++)
{
resalloc[p][k]+=newreq[k]; totalloc[k]+=newreq[k];
}
for(k=1;k<=r;k++)
{
if(totext[k]-totalloc[k]<=r;k++)
simalloc[k]=totalloc[k];
for(s=1;s<=n;s++)
for(i=1;i<=n;i++)
{
if(active[i]==1)
{
j=0;
OUTPUT:
Enter the no of resources: 4
Enter the no of resource classes: 3
Enter the total existed resources in each class: 3 2 2 Enter the allocated resources: 1 0 0 5 1 1 2 1 1 0 0 2 Enter the
process making the new request: 2
Enter the requested resource: 1 1 2
Enter the processes which are n blocked or running: Process 1: 1 2 Process 3: 1 0
Process 4: 1 0 Deadlock will occur
3. If the quantum time of round robin algorithm is very large, then it is equivalent to:
(A) First in first out
(B) Shortest Job Next
(C) Lottery scheduling
Explanation: Shortest job next may lead to process starvation for processes which will require a long time to
complete if short processes are continually added.
8. Which of the following process scheduling algorithm may lead to starvation
(A) FIFO
(B) Round Robin
(C) Shortest Job Next
(D) None of the above
Answer: (C)
Explanation: Shortest job next may lead to process starvation for processes which will require a long time to
complete if short processes are continually added.
9. Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6,
respectively. How many context switches are needed if the operating system implements a shortest remaining time
first scheduling algorithm? Do not count the context switches at time zero and at the end.
(A) 1
(B) 2
(C) 3
(D) 4
Answer: (B)
20. Logical memory is broken into blocks of the same size called _________.
a) frames
b) pages
c) backing store
d) None of these
Answer: b
21. Every address generated by the CPU is divided into two parts : (choose two)
a) frame bit
b) page number
c) page offset
d) frame offset
Answer: b and c
22. The _____ table contains the base address of each page in physical memory.
a) process
b) memory
c) page
d) frame
Answer: c