0% found this document useful (0 votes)
24 views67 pages

OS Lab Manual (02.07.24)

OS

Uploaded by

Hare Ram Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views67 pages

OS Lab Manual (02.07.24)

OS

Uploaded by

Hare Ram Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 67

DEPARTMENT OF INFORMATION TECHNOLOGY

LAB MANUAL

SUBJECT: OPERATING SYSTEM LAB


[RCS -451]

Prepared by Approved by
Mr. Ashish Kumar Srivastava Prof. (Dr.) Mahendra Sharma
Index

SI. NO. Particulars Page


1 Vision, Mission (Institute) i
2 Vision, Mission (Department) ii
3 COs iii
4 POs and PSOs iv
5 CO-PO mapping v
6 Syllabus as per AKTU vi
7 List of Experiments vii
8 DO’s & Don’ts viii
9 Safety Rules ix
VISION AND MISSION OF THE INSTITUTE

Vision:

To be among the renowned institutions providing engineering and management education of


excellence, empowered with research, innovation and entrepreneurship with high ethical values,
catering to the needs of industry and society.

Mission:

1. To offer state of the art undergraduate and postgraduate program.


2. To be a learner centric institute imbibing experimental innovation and lifelong learning
skills, addressing societal problems with high ethical values for nation building.
3. To deliver changing demands of industry and academia through our stakeholders.
4. To contribute as a professional leader in the growing field of entrepreneurship and research.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING

VISION AND MISSION OF THE DEPARTMENT

Vision:
To produce competent IT Professionals empowered with Research Aptitude and high ethical
values and cater the need of Industry and society.

Mission:

TTo attain academic and professional excellence with collective efforts of all stakeholders through:
1. Research – To impart quality education with innovative teaching learning processes to develop a culture
of research and innovation.
2. Industry – Interact with industry academia for better employability of students.
3. Ethical Values/ Society – To inculcate ethical values and social responsibility in students &
professional excellence with collective efforts of all stakeholders through:
1. Research – To impart quality education with innovative teaching learning processes to
develop a culture of research and innovation.
2. Industry – Interact with industry academia for better employability of students.
3. Ethical Values/ Society – To inculcate ethical values and social responsibility in students.
DEPARTMENT OF INFORMATION TECHNOLOGY

OPERATING SYSTEM LAB [RCS-451]

Course Outcomes (COs)


At the end of this course students will demonstrate the ability to:

CO 1: Design and implement various Non Pre-emptive CPU scheduling Algorithm's.

CO 2: Design and implement various Pre-emptive CPU scheduling Algorithm's.

CO 3: Apply various deadlock policies & memory management concepts and verify the performance.

CO 4: Implement various page replacement algorithms and verify the associated performance.

CO 5: Apply Disk scheduling algorithms and analyze the performance.


DEPARTMENT OF INFORMATION TECHNOLOGY

Program Outcomes (POs):

Students of this Program are expected to demonstrate:

PO1 - Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,
and an engineering specialization to the Solution of complex engineering problems.

PO2 - Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.

PO3 - Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration 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 valid 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 responsibilities relevant to the professional
engineering practice.

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 norms of
the engineering practice.

PO9 - Individual and Team Work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.

PO10 - Communication: 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.

PO12 - Life-long Learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
PROGRAM SPECIFIC OUTCOMES:

PSO1: Apply and acquire knowledge of computer networks in implementation of communication and
reliable network systems.

PSO2: Design and implement knowledge based discovery by using the concept of DBMS

CO-PO Mapping:

Course
P PO PO PO PO PO PO PO PO PO PO PSO PSO
Outcome PO1
O2 3 4 5 6 7 8 9 10 11 12 1 2
s
CO PO1 P PO PO PO5 PO6 PO7 PO PO PO PO PO PSO PSO
O2 3 4 8 9 10 11 12 1 2
CO1 2 3 1 1 2 2 2 1
CO2 3 2 2 3 2 2 2 2
CO3 3 2 2 3 2 2 2 2
CO4 3 2 2 3 2 2 2 2
CO5 3 2 2 3 2 2 2 2
2.2 1.8 2.6 2.0 1
Average 2.80 2.00 2.00 1.80
0 0 0 0

3 – High; 2 – Medium; 1 – Low


DEPARTMENT OF INFORMATION TECHNOLOGY
OPERATING SYSTEM LAB [RCS-451]

SUGGESTIVE LIST OF EXPERIMENTS AS PER AKTU

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
DEPARTMENT OF INFORMATION TECHNOLOGY

OPERATING SYSTEM LAB [RCS-451]

LIST OF EXPERIMENTS:

S.NO. Experiment name Page no.


1. Study of hardware and software requirements of different operating
1 1
systems (UNIX,LINUX,WINDOWS XP, WINDOWS7/8 )
2. Execute various UNIX system calls for i. Process management ii.
2 6
File management iii. Input/output Systems calls
3. Implement CPU Scheduling Policies: i. SJF ii. Priority iii. FCFS iv.
3 12
Multi-level Queue
4. Implement file storage allocation technique: i. Contiguous(using
4 array) ii. Linked –list(using linked-list) iii. Indirect allocation 16
(indexing)
5. Implementation of contiguous allocation techniques: i. Worst-Fit ii.
5 20
Best- Fit iii. First- Fit
6. Calculation of external and internal fragmentation i. Free space list
6 23
of blocks from system ii. List process file from the system
7. Implementation of compaction for the continually changing memory
7
layout and calculate total movement of data
29
8. Implementation of resource allocation graph RAG)
8 33
9. Implementation of Banker‟s algorithm
9 37
10. Conversion of resource allocation graph (RAG) to wait for graph
10 39
(WFG) for each type of method used for storing graph.
Value Added Experiment
Implement the solution for Bounded Buffer (producer-
11 consumer)problem using inter process communication techniques- 42
Semaphores
Implement the solutions for Readers-Writers problem using inter
12 45
process communication technique –Semaphore
DEPARTMENT OF INFORMATION TECHNOLOGY

OPERATING SYSTEM LAB [RCS-451]

Lab Instructions

 Lab should be maintained clean, organized, and properly lighted.


 Keep bags outside the lab.
 Don’t make noise and Grouping in lab.
 Follow lab manuals and Faculty instructions to perform lab Experiments strictly.
 Follow discipline in lab during performing experiments.
 Reach on time in lab.
 Return all materials and equipment to their designated places after the lab.
 Don’t use Mobile in Lab.
DEPARTMENT OF INFORMATION TECHNOLOGY

OPERATING SYSTEM LAB [RCS-451]

SAFETY MEASURES FOR LAB


 Know the location of the fire extinguisher and the first aid box and
how to use them in case of an emergency.
 Report any broken plugs or exposed electrical wires to your
lecturer/lab assistant immediately.
 Don’t bring flammable eatables or liquids inside lab.
 Avoid stepping on electrical wires or any other computer cables.
 Do not open the system unit casing or monitor casing particularly
when the power is turned on. Some internal components hold high
electric voltages, which can be fatal.
 Do not insert metal objects such as clips, pins and needles into the
computer casings. They may cause fire.
 Do not touch, connect or disconnect any plug or cable without your
lecturer/laboratory technician’s permission.
Experiment No. 1
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 kernel
 Command line interface
LINUX:
Hardware Requirements:

 Minimum of 512MB of RAM


 Minimum of 20GB of free hard disk space
 Pentium-compatible processor
Software Requirements:

 Linux kernel
 Graphical User Interface (GUI)
 Command line interface
WINDOWS XP:
Hardware Requirements:

 Minimum of 64MB of RAM (128MB recommended)


 Minimum of 1.5GB of free hard disk space
 Pentium-compatible processor
Software Requirements:

 Windows XP operating system


 DirectX 9.0c or higher
WINDOWS 7/8:
Hardware Requirements:

 Minimum of 1GB of RAM (2GB recommended)


 Minimum of 16GB of free hard disk space (20GB recommended)
 1 GHz or faster processor
Software Requirements:

 Windows 7/8 operating system


 DirectX 9 graphics device with WDDM 1.0 or higher driver
 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.

 A Pentium-compatible processor is usually sufficient, but some distributions may have


specific processor requirements.

 Software Requirements:

 The Linux kernel is the core of the operating system and provides the basic functionality
for all other software to run on top of.
 Most Linux distributions include a graphical user interface (GUI) that provides a visual
way to interact with the system. Some distributions may also offer alternative interfaces,
like a command line interface (CLI) or a text-based interface.

 The CLI is the traditional way to interact with Linux, using text-based commands to
perform tasks like navigating the file system, launching applications, and managing users
and permissions.

 WINDOWS XP:

 Hardware Requirements:

 64MB of RAM is the minimum requirement for Windows XP to run, but 128MB or more
is recommended for better performance.

 1.5GB of free hard disk space is the minimum requirement, but more is recommended
depending on the intended use case.

 A Pentium-compatible processor running at 233 MHz or faster is required.

 Software Requirements:

 Windows XP is a complete operating system that includes a graphical user interface and
support for a wide range of hardware and software applications.

 DirectX 9.0c or higher is required to run some advanced graphics applications and games.
WINDOWS 7/8:
Hardware Requirements:
Windows 7/8 require at least 1GB of RAM to run, but 2GB or more is recommended for
better performance.
At least 16GB of free hard disk space is required for a 32-bit installation of Windows 7/8,
or 20GB for a 64-bit installation.
A 1 GHz or faster processor is required for both 32-bit and 64-bit versions.
Software Requirements:
Windows 7/8 include a graphical user interface and support for a wide range of hardware
and software applications.
DirectX 9 graphics device with WDDM 1.0 or higher driver is required to run some
advanced graphics applications and games.

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.
Microsoft Office Suite, which includes popular productivity applications like Word, Excel,
and PowerPoint, can be purchased separately or as part of a subscription to Microsoft 365.
It's worth noting that these are just the recommended requirements, and the actual hardware
and software requirements for Windows 10/11 can vary depending on the specific version
of the operating system and its intended use case. For example, running more demanding
software applications or games may require higher-end hardware.

Difference between 32 bit and 64 bit os


The primary difference between a 32-bit and 64-bit operating system (OS) is the amount of
memory it can address. Here are some key differences between the two:

 Memory: A 32-bit OS can address up to 4GB of RAM, while a 64-bit OS can


address much more memory, usually up to 2^64 bytes of RAM, which is essentially
unlimited for practical purposes.
 Performance: 64-bit operating systems can perform faster than their 32-bit
counterparts on machines with a 64-bit processor, due to the larger memory address
space and the ability to perform more simultaneous calculations.
 Compatibility: 32-bit software applications can run on both 32-bit and 64-bit
operating systems, but 64-bit software applications can only run on a 64-bit
operating system. This means that some older hardware or software may not work
on a 64-bit OS.
 Security: 64-bit operating systems can provide better security than 32-bit operating
systems, as they can take advantage of hardware-based security features such as
Data Execution Prevention (DEP), which helps to prevent malicious code from
executing.
Overall, if you have a 64-bit processor and more than 4GB of RAM, you may want to
consider a 64-bit operating system to take full advantage of your hardware. However, if
you are running older software or hardware, a 32-bit operating system may be more
compatible

Experiment No. 2

Experiment 2. Execute various UNIX system calls for i. Process management ii. File
management iii. Input/output Systems calls

Objective : To make familiar with unix system calls for the process, file and input output
management.
Steps to be followed:
We will use online linuxcompiler : onecompiler.com
Program: Use of fork system call
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
intmain()
{
fork();
printf("Using fork() system call\n");
return 0;
}
Output:

Using fork() system call

Using fork() system call

Program : use of process id system calls

#include <stdio.h>

#include <sys/types.h>

#include <unistd.h>
intmain()

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
Experiment No. 3
Experiment -3
Experiment Objective-: C Program for FCFS CPU scheduling algorithm
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];
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\tP_time\tw_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\navg waiting time=%f",tot,avg);
getch();
}

ProgramOutput:
enter no of processes: 5
Enterprocess1 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
eee 1 14
total waiting time=34
avg waiting time=6.80
Experiment No. 4

Experiment-4
Experiment Objective: C program for SJF CPU Scheduling Algorithm
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]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(pt[i]>pt[j])
{
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];
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_nameP_time w_time

eee 1 0
ccc 2 1
bbb 3 3
aaa 4 6
ddd 5 10
total waiting time=20
avg waiting time=4.00
Experiment No. 5

Experiment-5
Experiment Objective: Shortest Remaining Time First ( SRTF) CPU scheduling in c
Program Prerequisite:- Basic knowledge of C programming and Concept of related Operating
system algorithm
Program Code:-
#include <stdio.h>
intmain()
{
int a[10],b[10],x[10],i,j,smallest,count=0,time,n;
double avg=0,tt=0,end;
printf("enter the number of Processes:\n");
scanf("%d",&n);
printf("enter arrival time\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("enter burst time\n");
for(i=0;i<n;i++)
scanf("%d",&b[i]);
for(i=0;i<n;i++)
x[i]=b[i];

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];
}
}
printf("\n\nAverage waiting time = %lf\n",avg/n);
printf("Average Turnaround time = %lf",tt/n);
return 0;
}

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 No. 6

Experiment-6
ExperimentObjective:-C Program for Priority CPU Scheduling Algorithm

Program Prerequisite:- Basic knowledge of C programming and Concept of related Operating system
algorithm
Program Code:-
#include<stdio.h>
#include<conio.h>
void main()
{
char p[10][5],temp[5];
inti,j,pt[10],wt[10],totwt=0,pr[10],temp1,n;
float avgwt;
clrscr();
printf("enter no of processes:");

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();
}

Program Output:
enter no of processes: 5
enter process1 name: aaa
enter process time: 4
enter priority:5
enter process2 name: bbb
enter process time: 3
enter priority:4
enter process3 name: ccc
enter process time: 2
enter priority:3
enter process4 name: ddd
enter process time: 5
enter priority:2
enter process5 name: eee
enter process time: 1
enter priority:1

p_name P_time priority w_time


eee 1 1 0
ddd 5 2 1
ccc 2 3 6
bbb 3 4 8
aaa 4 5 11

total waiting time=26


avg waiting time=5.20
Experiment No. 7
Experiment -7
ExperimentObjective:-C program for Round Robin CPU Scheduling Algorithm

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>
#include<string.h>
void main()
{
char p[10][5];
int et[10],wt[10],timer=3,count,pt[10],rt,i,j,totwt=0,t,n=5,found=0,m;
float avgwt;
clrscr();
for(i=0;i<n;i++)
{
printf("enter the process name : ");
scanf("%s",&p[i]);
printf("enter the processing time : ");
scanf("%d",&pt[i]);
}
m=n;
wt[0]=0;
i=0;
do
{
if(pt[i]>timer)
{
rt=pt[i]-timer;
strcpy(p[n],p[i]);
pt[n]=rt;
et[i]=timer;
n++;
}
else
{
et[i]=pt[i];
}
i++;
wt[i]=wt[i-1]+et[i-1];
}while(i<n);

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

p_name p_time w_time


aaa 4 9
bbb 3 3
ccc 2 6
ddd 5 10
eee 1 11

total waiting time : 39


average waiting time : 7.8000
Experiment No. 8

Experiment-8
Experiment Objective:-Multi Level Queue Scheduling
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;
inttr;
intcsource=0;
intcuser=0;
intbtsource[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;
}
for(i=0;i<cuser;i++){
p[i+csource]=puser[i];
bt[i+csource]=btuser[i];
su[i+csource]=1;
}
for(i=0;i<n;i++){
printf("%d %d",p[i],bt[i]);

}
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

0 51 32 83 44 5
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 No. 9

Experiment-9
ExperimentObjective:-Program for FIFO page replacement algorithm
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();
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();
}
void display()
{
inti;
printf("\n");
for(i=0;i<3;i++)
printf("%d\t",fr[i]);
}
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

Number of page faults: 6

Experiment No. 10

Experiment -10

ExperimentObjective:-C program for LRU page replacement algorithm

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;
clrscr();
for(i=0;i<3;i++)
{
fr[i]=-1;
}
for(j=0;j<12;j++)
{
flag1=0,flag2=0;
for(i=0;i<3;i++)
{
if(fr[i]==p[j])
{
flag1=1;
flag2=1;
break;
}
}
if(flag1==0)
{
for(i=0;i<3;i++)
{
if(fr[i]==-1)
{
fr[i]=p[j];
flag2=1;
break;
}
}
}
if(flag2==0)
{
for(i=0;i<3;i++)
fs[i]=0;
for(k=j-1,l=1;l<=frsize-1;l++,k--)
{
for(i=0;i<3;i++)
{
if(fr[i]==p[k])
fs[i]=1;
}
}
for(i=0;i<3;i++)
{
if(fs[i]==0)
index=i;
}
fr[index]=p[j];
pf++;
}
display();
}
printf("\n no of page faults :%d",pf);
getch();
}
void display()
{
inti;
printf("\n");
for(i=0;i<3;i++)
printf("\t%d",fr[i]);
}

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

Experiment No. 11

Experiment-11
Program Objective:-Simulation of Paging technique of Memory Management
Program Prerequisite:- Basic knowledge of C programming and Concept of related Operating
system algorithm
Program Code:-
#include<stdio.h>
#include<conio.h>
intmain()
{
intpage[10], pagetab[10], pframe[2][2], I,j;
int size, msize, cnt, t,k,pos,logadd,m=0;
intframeno;
long int l;
inti;
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;
break;
}
else
continue;
}
printf("\nPage number : %d", pos);
frameno=pagetab[pos];
printf("\nThe frame number is %d\n", frameno);
printf("\nThe corresponding physical address is %d", (frameno*size)+m);
}
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 No. 12
Experiment 12
Objective :Calculation of external and internal fragmentation i. Free space list of blocks
from system ii. List process file from the system

MUTIPROGRAMMING VARIABLE TASK


To program MVT using c programming
ALGORITHM:
Step 1: Declare the necessary variables.
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.
Step 6: Then the external fragmentation of each process must be calculated.

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();
}

SAMPLE INPUT AND OUTPUT:


Input:
Enter the memory capacity: 80 Enter no of processes: 2
Enter memory req for process1: 23
Output:
The memory allocated for process1 is: 80 Remaining memory is: 57
External fragmentation for this process is: 57 Enter memory req for process2: 52
The memory allocated for process2 is: 57 Remaining memory is: 5
External fragmentation for this process is: 5

MUTIPROGRAMMING FIXED TASK


OBJECTIVE: To program MFT using c programming
ALGORITHM:

Step 1: Declare the necessary variables.

Step 2: Get the memory capacity and number of processes.

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.
Step 5: If the required memory not available then the process will not be allocated to that partition.
Step 6: Calculate the external fragmentation and total number of fragmentation.

SOURCE CODE:
#include<stdio.h>
#include<conio.h>
intmain()
{
intm,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;
}

SAMPLE INPUT AND OUTPUT:


Input:
Enter the memory size: 80 Enter the no of partitions: 4 Each partition size: 20
Enter the number of processes: 2 Enter the memory req for process1: 18

Output:
Process1 is allocated in partn1
Internal fragmentation for process1 is: 2 Enter the memory req for process2: 22 Process2 is not
allocated in partn2 External fragmentation for process2 is: 18

Process memory allocated


1 20 18
2 20 22
The tot no of fragmentation is: 20

Experiment No. 13
Experiment :13

Implement file storage allocation technique: i. Contiguous(using array) ii. Linked –list(using
linked-list) iii. Indirect allocation (indexing)

OBJECTIVE:Toimplementsequentialfileallocationtechnique.
ALGORITHM:

Step1:Starttheprogram.

Step2:Getthe numberoffiles.

Step3:Getthememoryrequirementofeach file.

Step4:Allocatetherequiredlocationstoeachinsequentialorder.

a).Randomlyselectalocationfromavailablelocations1=random(100);b).

Check whether the required locations are free from the selected

location.c).Allocateand set flag=1 totheallocatedlocations.

Step 5: Print the results fileno, length , Blocks

allocated.Step6: Stopthe program.

SOURCECODE:
#include<stdio.h>
main()
{
intf[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("\nthefileisallocatedtodisk");
printf("\n if u want to enter more files?(y-1/n-
0)");scanf("%d",&c);
if(c==1)
goto
X;elsee
xit();
getch();
}

Output:
Enterthestartingblock&lengthoffile 410

4->1
5->1
6->1
7->1
8->1
9->1
10->1
11->1
12->1
13->1
Thefileisallocatedtodisk
Ifyouwanttoentermorefiles?(Y-1/N-o)
LINKEDFILEALLOCATION

OBJECTIVE:

To write a C program to implement File Allocation concept using the technique Linked

ListTechnique.

ALGORITHM:

Step1:StarttheProgram
Step2:Getthenumberoffiles.

Step 3: Allocate the required locations by selecting a location

randomlyStep4: Check whetherthe selectedlocationis free.

Step 5: If the location is free allocate and set flag =1 to the allocated

locations.Step6: Printthe resultsfile no,length, blocksallocated.

Step7:Stoptheexecution
SOURCECODE:
#include<stdio.h>
main()
{
intf[50],p,i,j,k,a,st,len,n,c;
clrscr();
for(i=0;i<50;i+
+)f[i]=0;
printf("Enter how many blocks that are already
allocated");scanf("%d",&p);
printf("\nEnter the blocks no.s that are already
allocated");for(i=0;i<p;i++)
{
scanf("%d",&a);
f[a]=1;
}
X:
printf("Enter the starting index block &
length");scanf("%d%d",&st,&len);
k=len;for(j=st;j<(k+s
t);j++)
{
if(f[j]==0)
{f[j]=
1;
printf("\n%d->%d",j,f[j]);
}
else
{
printf("\n %d->file is already
allocated",j);k++;
}
}
printf("\n If u want to enter one more file? (yes-1/no-
0)");scanf("%d",&c);
if(c==1)
goto
X;elsee
xit();
getch();}

OUTPUT:
Enterhowmany blocksarealreadyallocated3
Enter the blocks no’s that are already allocated4 7
9Enterthe startingindexblock &length 3
7
3-> 1
4-> File is already
allocated5->1
6->1
7-> File is already
allocated8->1
9-> File is already
allocated10->1
11->1
12->1
Ifuwanttoenteronemorefile?(yes-1/no-0)

INDEXEDFILEALLOCATION

OBJECTIVE:

To write a C program to implement File Allocation concept using the technique

indexedallocationTechnique

ALGORITHM:

Step1:StarttheProgram

Step2:Getthe numberoffiles.

Step3:Getthememoryrequirementofeach file.

Step 4: Allocate the required locations by selecting a location

randomly.Step5: Printthe resultsfile no,length, blocksallocated.

Step7:Stoptheexecution.
SOURCECODE:

#include<stdio.h>
int
f[50],i,k,j,inde[50],n,c,count=0,p;ma
in()
{
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(
"\nallocated");
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;elseex
it();
getch();
}

OUTPUT:

Enterindexblock9
Enterno offilesonindex

31 2 3
AllocatedFi
le indexed9-
> 1:1
9-> 2:1
9->3:1
Enter1toentermore filesand0 toexit
Experiment No. 14

Experiment 14 :SIMULATEBANKERSALGORITHMFORDEADLOCKAVOIDANCE

OBJECTIVE:

TowriteaCprogramtoimplementbankersalgorithmfordeadlockavoidance

ALGORITHM:

Step1:StarttheProgram

Step 2: Get the values of resources and

processes.Step3: Getthe avail value.

Step4:Afterallocationfindtheneedvalue.

Step5:Checkwhether itspossibletoallocate.Ifpossibleitissafestate

Step 6: If the new request comes then check that the system is in safety or not if we allow

therequest.

Step7:Stoptheexecution
SOURCECODE:

#include<stdio..h>
#include<conioh>
voidmain()
{
intn,r,i,j,k,p,u=0,s=0,m;
intblock[10],run[10],active[10],newreq[10];
intmax[10][10],resalloc[10][10],resreq[10][1];inttotalloc[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;
elseactive[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;
for(k=1;k<=r;k++)
{
if((totext[k]-simalloc[k])<(max[i][k]-resalloc[i][k]))
{
J=1;
break;
}}}
if(j==0)
{
active[i]=0;for(k=1;k<=r;k++)simalloc[k]=resalloc[i][k];
} }m=0;
for(k=1;k<=r;k++)resreq[p][k]=newreq[k];printf("Deadlockwilln'toccur");
}
Else
{
for(k=1;k<=r;k++)
{
resalloc[p][k]=newreq[k];
totalloc[k]=newreq[k];
}
printf("Deadlockwilloccur");
}
getch();
}

OUTPUT:
Enterthenoofresources:4
Enterthenoofresourceclasses:3
Enter the total existed resources in each class: 3 2 2Enter the allocated resources: 1 0 0 5 1 1 2 1 1 0 0
2Enterthe processmaking the newrequest: 2
Entertherequestedresource:112
Enter the processes which are n blocked or running: Process 1: 1 2Process3: 10
Process 4: 1 0Deadlockwilloccur
Sample question for Viva-Voce

1. Briefly explain FCFS.


FCFS is short for First-come, first-served, and is one type of scheduling algorithm. In this scheme, the
process that requests the CPU first is allocated the CPU first. Implementation is managed by a FIFO
queue.

2. What are turnaround time and response time?


Turnaround time is the interval between the submission of a job and its completion. Response time is the
interval between submission of a request, and the first response to that request.

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
(D) None of the above
Answer: (A)

4. Which of the following scheduling algorithms is non-preemptive?


(A) Round Robin
(B) First-In First-Out
(C) Multilevel Queue Scheduling
(D) Multilevel Queue Scheduling with Feedback
Answer: (B)
5. The scheduling in which CPU is allocated to the process with least CPU-burst time is called
(A) Priority Scheduling (B) Shortest job first Scheduling (C) Round Robin Scheduling (D) Multilevel
Queue Scheduling
Ans: (B)
6. Differentiate between pre-emptive and non-pre-emptive scheduling.
Ans: In a pre-emptive scheduling approach, CPU can be taken away from a process if there is a need
while in a non-pre-emptive approach if once a process has been given the CPU, the CPU cannot be taken
away from that process, unless the process completes or leaves the CPU for performing an Input Output.
DC14 System Software and Operating System 15 Pre-emptive scheduling is more useful in high priority
process which requires immediate response, for example in real time system. While in nonpreemptive
systems, jobs are made to wait by longer jobs, but treatment of all processes is fairer.
7. 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.
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)

11. what do you understand by priority scheduling.


Processes scheduling in which the scheduler selects tasks to run based on their priority as opposed to, say,
a simple round-robin. Priorities may be static or dynamic. Static priorities are assigned at the time of
creation, while dynamic priorities are based on the processes' behaviour while in the system.

12. difference between priority and SJF scheduling algorithm


A priority number (integer) is associated with each process, The CPU is allocated to the process with the
highest priority (smallest integer ≡ highest priority).
1. Preemptive
2. nonpreemptive
SJF is a priority scheduling where priority is the predicted next CPU burst time.
Problem ≡ Starvation – low priority processes may never execute.
Solution ≡ Aging – as time progresses increase the priority of the process.
13. What is concept of RR Scheduling.

Round-robin:-round-robin policy is a method in which every process gets its time slice. after executing a
process for certain time slice..if the job is not completed in that time it will be thrown into waiting state
and the next job gets the timeslice and will be executed..and the process that was in waiting state will get
processor time after the remaining processes are completed.
14. Which of the following statements are true?
I. Shortest remaining time first scheduling may cause starvation
II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time
(A) I only
(B) I and III only
(C) II and III only
(D) I, II and III
Answer: (D)
15. What is basic idea behind LRU
A good approximation to the optimal algorithm is based on the observation that pages that have been
heavily used in the last few instructions will probably be heavily used again in the next few. Conversely,
pages that have not been used for ages will probably remain unused for a long time. This idea suggests a
realizable algorithm: when a page fault occurs, throw out the page that has been unused for the longest
time. This strategy is called LRU (Least Recently Used) paging.

16. What is problem related to LRU


To fully implement LRU, it is necessary to maintain a linked list of all pages in memory, with the most
recently used page at the front and the least recently used page at the rear. The difficulty is that the list
must be updated on every memory reference. Finding a page in the list, deleting it, and then moving it to
the front is a very time consuming operation, even in hardware (assuming that such hardware could be
built).

17. Difference between FIFO and LRU


Answer: FIFO stands for First In First Out. There is less overhead because there is no need to keep track
of the pages. However this is not necessarily efficient because more frequently used pages can still be
removed because was the first in.
18. What are local and global page replacements?
Local replacement means that an incoming page is brought in only to the relevant process address space.
Global replacement policy allows any page frame from any process to be replaced. The latter is
applicable to variable partitions model only.

19. Physical memory is broken into fixed-sized blocks called ________.


a) frames
b) pages
c) backing store
d) None of these
Answer: a

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

You might also like