Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
38 views

Lab Manual Report

This document contains the vision, mission, program outcomes, course outcomes, and experiments for an operating systems lab manual. The vision is to be a leader in science and technology innovations. The mission is to provide broad engineering education and inculcate skills like problem solving. The program outcomes include applying engineering knowledge, designing solutions, and communicating effectively. The course outcomes cover operating system concepts. The document lists regulations for the lab and 10 experiments on CPU scheduling, memory management, and disk scheduling algorithms.

Uploaded by

Sanskar wadhwa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Lab Manual Report

This document contains the vision, mission, program outcomes, course outcomes, and experiments for an operating systems lab manual. The vision is to be a leader in science and technology innovations. The mission is to provide broad engineering education and inculcate skills like problem solving. The program outcomes include applying engineering knowledge, designing solutions, and communicating effectively. The course outcomes cover operating system concepts. The document lists regulations for the lab and 10 experiments on CPU scheduling, memory management, and disk scheduling algorithms.

Uploaded by

Sanskar wadhwa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 45

IPSACADEMYINDORE

INSTITUTEOFENGINEERING&SCIENCECOMP
UTER SCIENCE &
ENGINEERINGDEPARTMENT

LAB MANUAL
(PCC-CSIT503)
OperatingSystem

Name …………………………………………………..

Branch ………. Year………….. Semester……………

Enrollment No. …………………………………………..


CONTENTS

1. Vision Mission of the Institute

2. Vision Mission of the Department

3. PEOs

4. POs

5. COs

6. Content beyond Syllabus. (if any)

7. Laboratory Regulations and Safety Rules

8. Index

9. Experiments

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Vision of the Institute

To be the fountainhead of novel ideas & innovations in science & technology & persist to be a
foundation of pride for all Indians.

Mission of the Institute

1. To provide value based broad Engineering, Technology and Science where education in students is
urged to develop their professional skills.

2. To inculcate dedication, hard work, sincerity, integrity and ethics in building up overall professional
personality of our student and faculty.

3. To inculcate a spirit of entrepreneurship and innovation in passing out students.

4. To instigate sponsored research and provide consultancy services in technical, educational, and
industrial areas.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Vision of the Department

Attaining global recognition in computer science and engineering education, research, and training to
meet the growing needs of the industry and society.

Mission of the Department

Provide quality undergraduate and postgraduate education, in both the theoretical and applied
foundations of computer science, and train students to effectively apply this education to solve real-
world problems, thus amplifying their potential for lifelong high-quality careers.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Program Education Objectives (PEOs)

1. To prepare students for successful careers in software industry that meet the needs of Indian and
multinational companies.

2. To develop the skills among students to analyze real world problem & implement with computer
engineering solution and in multidisciplinary projects.

3. To provide students with solid foundation in mathematical, scientific and engineering fundamentals
to solve engineering problems and required to pursue higher studies.

4. To develop the ability to work with the core competence of computer science & engineering i.e.,
software engineering, hardware structure & networking concepts so that one can find feasible
solution to real world problems.

5. To inseminate in students professional and ethical attitude, effective communication skills,


teamwork skills, multidisciplinary approach, and an ability to relate engineering issues to broader
social context.

6. To motivate students’ perseverance for lifelong learning and to introduce them to professional
ethics and codes of professional practice.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Program Outcomes (POs)

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, 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 teamwork: 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.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


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-long learning in the broadest context of technological change

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Program Specific Outcomes (PSOs)

1. Apply Concepts in core areas of computer science -Data Structures, Database Management System,
Operating System, Computer Networks and Software Engineering to solve technical issues.

2. Apply Software Engineering principal and practices to provide software solutions.

3. Ability to work in team and apply the knowledge acquired to develop new real-life system and able
to adapt societal need of future.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Course Outcomes (COs)

PCC-CS503.1State the core concepts of operating system, evolution, and types of operatingsystem.(BT-
1)

PCC-CS503.2Illustrate process concepts, intercrosses communication and deadlock.(BT-3)

PCC-CS503.3Illustrate memory management techniques. (BT-3)

PCC-CS503.4 Describe the concept of file and disk management.(BT-2)

PCC-CS503.5State the core concepts of network, distributed and multiprocessor operatingsystem.


(BT-1)

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Content Beyond Syllabus (if any)

1. Real Time Operating System.

2. Highest Response Ratio First CPU Scheduling.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Laboratory Regulations and Safety Rules

1. Without Prior permission do not enter the Laboratory.

2. While entering the LAB students should wear their ID cards.

3. The students should come with proper uniform.

4. Student should not use mobile phone inside the laboratory.

5. Students should sign in the LOGIN REGISTER before entering the laboratory.

6. Students should come with observation and record notebook to the laboratory.

7. Do not change any computer setting.

8. Students should maintain silence inside the laboratory.

9. After completing the laboratory exercise, make sure to SHUTDOWN the system properly.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


List of Experiments

S.No. Experiment Name Date Grad Sign


e

1. Case Study of different Operating Systems and evaluation


of
Operating System. (CO1)

2. Comparative study of UnixLinux and windows operating


system. (CO1)

3. Write a program to implement FCFS CPU scheduling


algorithm (CO2)

4. WriteaprogramtoimplementSJFCPUscheduling algorithm
(CO2)

5. Write a program to implement Priority CPU Scheduling


algorithm. (CO2)

6. Write a program to implement Round Robin CPU


scheduling algorithm (CO2)

7. Write a program to implement Banker’s algorithms. (CO2)

8. Write a program to simulate memory allocation strategies


(Firstfit, best fit and Worst fit). (CO3)

9. Write a program to implement various pagereplacement


algorithms (CO3)

10. Write a program to implement various Disk scheduling


Algorithms. (CO4)

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiments Beyond Lab Manual

S. No. Experiment Name Date Grade Sign

1. Write a program to implement Highest Response Ratio


Next CPU Scheduling algorithm.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 1

Case Study of different Operating Systems and evaluation of Operating System

An operating system(OS) is system software that manages computer hardware and


software resources and provides common services for computer programs. All computer
programs, excluding firmware, require an operating system to function.
For hardware functions such as input and output and memory allocation, the operating
system acts as an intermediary between programs and the computer hardware, although the
application code is usually executed directly by the hardware and frequently makes system calls to
an OS function or is interrupted by it. Operating systems are found on many devices that contain a
computer – from cellular phones and video game consoles to web servers and supercomputers.

Types of operating systems:-

 Single and multitasking: -A single-tasking system can only run one program at a time, while
a multi-tasking operating system allows more than one program to be running in
concurrency. This is achieved by time-sharing, dividing the available process or time
between multiple processes that are each interrupted repeatedly in time slices by a task-
scheduling subsystem of the operating system. Multi-tasking may be characterized in
preemptive and co-operative types. In pre-emptive multitasking, the operating system
slices the CPU time and dedicates a slot to each of the programs. Unix-like operating
systems, e.g., Solaris, Linux support pre-emptive multitasking.

 Single- and multi-user: -Single-user operating systems have no facilities to distinguish users,
but may allow multiple programs to run. Multi-user operating system extends the basic
concept of multi-tasking with facilities that identify processes and resources, such as disk
space, belonging to

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


multiple users, and the system permits multiple users to interact with the system at the
same time. Time-sharing operating systems schedule tasks for efficient use of the system
and may also include accounting software for cost allocation of process or time, mass
storage, printing, and other resources to multiple users.

 Distributed:-A distributed operating system manages a group of distinct computers and


makes them appear to be a single computer. The development of networked computers
that could be linked and communicate with each other gave rise to distributed computing.
Distributed computations are carried out on more than one machine. When computers in a
group work in cooperation, they forma distributed system.

 Templated:-In an OS, distributed and cloud computing context, templating refers to


creating a single virtual machine image as a guest operating system, then saving it as a tool
for multiple running virtual machines. The technique is used both in virtualization and
cloud computing management, and is common in large server warehouses.

 Embedded:-Embedded operating systems are designed to be used in embedded computer


systems. They are designed to operate on small machines like PDAs with less autonomy.
They are able to operate with a limited number of resources. They are very compactand
extremely efficient by design. Windows CE and Minix3 are some examples of embedded
operating systems.

 Real-time: -A real-time operating system is an operating system that guarantees to


process events or data by a specific moment in time. A real-time operating system may be
single-or multi-tasking, but when multitasking, it uses specialized scheduling algorithms so
that a deterministic nature of behavior is achieved.Anevent-driven system switches
between tasks based on their priorities or external events while time-sharing operating
systems switch tasks based on clock interrupts.

 Library: -A library operating system is one in which the services that a typical operating
systemprovides,suchasnetworking,areprovidedintheformoflibrariesandcomposedwiththeap
plication and configuration codeto construct a unikernel: a specialized, single address
space,machineimage thatcanbedeployedtocloudor embeddedenvironments.

EvolutionofOperatingSystems:-

 Batch Systems:-In order to improve the utilisation of computing resources, the concept of a
batchoperatingsystemwasdevised.Suchanoperatingsystemwasdevelopedin the mid-1950sbyGeneral
Motors for use on IBM mainframes, and was known as the monitor. The operator nowbatched
individual jobs together sequentially and placed them on an input device.The monitorwould load
and run one job at a time. On completion, each job returned control tothe monitor,which would then
load the next job. Control would also return to the monitorif anerror wasencountered. The results of
each job were sent to an output device such as a printer. Because
themonitorcontrolledthesequenceofevents,partoftheprogram(theresidentmonitor)hadtoresidein
memory. Other parts of the program were loaded as subroutines at the beginning of any job
thatrequired them.The monitor created some additional system overhead because itoccupied a

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


portionofmemoryandusedtheresources oftheprocessor.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


 Multiprogramming systems: - In a multiprogramming system,a running application can
requestanI/Ooperationbysendingasystemcalltotheoperatingsystem.Theoperatingsystemwillissuethe
necessary commands to the I/O device controller, and then initiate or continue the execution
ofanotherprogram.Multiprogrammingsystemsrelyonthegenerationofinterrupts,whicharebasically
signals sent bya hardware device to inform the processor that it has completed a task
(orhasencountered anerror). On receiptofaninterrupt,the processorpassescontrolbackto
theoperatingsystem,whichexecutesthenecessaryinterrupt-
handlingroutine.Multiprogrammingoperating systems require a high degree of sophistication, since
they are responsible for managingmemoryusage for,andschedulingtheexecution of, multipleprograms.

 Time sharing OS:-In order for the processor's time to be divided fairly between the
programscompeting for its use, the operating system interleaves the execution of each program in
short timeslots.Thisprocessisknownastime-
sharing,anditpreventsoneprogramfromhoggingtheprocessor to the detriment of other programs. In a
multiprogramming system there is inevitably thepossibility that, due to a programming error for
example, one program’scodewillattempt toaccess or overwrite memory that is being used by another
program. In addition to its other duties,therefore, the operating system must also ensure that programs
do not interfere with each other (forexamplebymodifyingeach other’s programcode ordata).

 Personal computers:- As early as the 1960s and 1970s, researchers were working on the idea of
apersonal computer. Alan Kay, who was working for IBM formulated the idea of a graphical
userinterface (or GUI). The interface he envisaged had all of the features we can now see in a
moderndesktop environment, including a separate window for each application, a menu-driven
applicationenvironment,andmanyotherfeaturesnowincommonuse.Then,AppledevelopedtheMacintosh;
for the first time, an operating system had been created that reflected the economic reality that
theoperatorwasnowafargreatercostfactorthanthecomputerhardwareorsoftware.Thecomputerwas
adapted to suit the operator rather than the other way round. Almost all operating systems nowoffer a
sophisticated, event-driven, graphical desktop environment designed primarily for ease ofuse.

 Parallel Operating Systems:- Parallel operating systems are designed to make efficient use
ofcomputerswith multiple processors,and manyoperating systems currentlyonthe market can
takefulladvantageofmultiple processorsif present, providing theapplication
programstheyarerunninghavebeenwrittenusingaprogramminglanguagethatsupportsmulti-
threading.Thegeneral idea is that different threads of the program canbeexecuted simultaneously,
speeding upthe execution of the program as a whole. Programswrittenforsingle-processor computers
canoftenrun on amulti-processorsystem,butcanonlyexecuteononeprocessor atatime.

 Real-time systems:- A real-time operating systemis one in which processing activity is


triggeredbyoneormorerandomexternalevents,eachofwhichwillinitiatetheexecutionofapredetermined
set of procedures that must be completed within rigid time constraints. Real-
timesystemsareoftendedicatedtohighlyspecializedapplications,suchasflyinganaircraftorcontrolling an
industrial process, where an input event must result in an immediate response. In theearly1980s,real-
time systemswereusedalmostexclusivelyforapplicationssuchas process

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


control. A process control system typically accepts analogue or digital sensor input, analyses
thedata,andtakes the appropriateaction.

 Distributed systems:- A distributed system is one in which various userresourcesreside


inseparatecomputersystemsconnectedbyanetwork. The computer systems
involvedmayhavediversehardwareandsoftwareplatforms,buttheuserispresentedwithauniformcomputin
genvironment thanks to a distributed system architecture that provides a standard
communicationsinterface.Thisintermediatelayerofsoftwarehidesthecomplexitycreatedbytheintercomm
unication of such diverse technologies. Microsoft's common objectmodel(COM)
wasanarchitecturedeveloped to handleinter-processcommunication between applicationsrunning
onthe same computer. Theirdistributedcommon objectmodel (DCOM)architecture is an extensionof
COM that enables inter-process communication to take place between applications running
ondifferentcomputersonanetwork.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. What is the hard and soft real time systems? (BT-1/CO-1)

Ans. An RTOS that can usually or generally meet a deadline is a soft real-time OS, but if it can meet a
deadline deterministically it is a hard real-time OS.

Q2. What is the main difference between multiprogramming and time-sharing OS? (BT-1/CO-1)

Ans. Main difference between multiprogramming and time sharing is that multiprogramming is the
effective utilization of CPU time, by allowing several programs to use the CPU at the same time but
time sharing is the sharing of a computing facility by several users that want to use the same facility at
the same time.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 2

Comparative study of UNIX Linux and Windows operating system

UNIX

Unix was initially composed in assembly language. Ken Thompson composed B, for the most
partaking into account BCPL, in view of his involvement in the MULTICS project. B was supplanted
by C, and Unix, revamped in C, formed into a vast, complex group of inter related working
frameworks which have been persuasive in each current operating systems. The Unix-like family is
a different gathering of operating system ,with a few note worthy sub-classifications as well as
System V , BSD, and Linux .The name “UNIX” is a brand name of The Open Group which permits it
for use with any operating system that has been appeared to comply with their definitions.

Linux
The Linux kernels began in 1991, as a venture of Linus Torvalds, while a college understudy in
Finland. He posted data related to his project on newsgroup for PC understudies and developers,
and got support and help from volunteers who achieved something in making a complete and
practical portion. On account of its open license model, the code of Linux kernel is accessible for
study and alteration, which brought about its utilization on an extensive variety of processing
hardware from super computers to smart watches.

Windows

Microsoft Windows is a group of exclusive operating system composed by Microsoft Corporation


and essentially focused to Intel design based PCs, with an expected 88.9 percent complete use
offer on Web associated computers. The most recent version is Windows 10.Windows 7
overwhelmed Windows XP as most basic form in use in 2011.Microsoft Windows was initially
released in 1985, as an operating domain consecutively on peak of MS-DOS ,which was standard
working framework dispatched on most Intel engineering PCs at the time.

LINUXVSUNIXVSWINDOWSOPERATING SYSTEM

Introduction:-
 Linux is an illustration of open source programming advancement and free of charge
operating system (OS).
 Unix is a system that is extremely main stream in colleges, organizations, big enterprises and
soon.
 MicrosoftWindowsissaidasprogressionofgraphicalinterfacesystemcreated, showcased,
and traded by Microsoft.
Use:-
 Linux can usually install on a broad range of PC software and hardware, going from
cellular phones, tablets PCs and video game relieves, to centralized servers and
supercomputers.
 The Unix system is utilized as a part of web servers, workstations and PCs. It plays an
important role for finance infrastructure and numerous 24×365. High accessibility

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


solutions.

 Windows is a system used on computer’s desktops, portable workstations, servers and a


few phones.
Users:-
 Linux is an operating system which is used by everybody; from home clients to engineers
and PC lovers a like
 .Unix system were produced fundamentally for servers, mainframes and workstations aside
from OSX , Which is intended for everybody. The Unix setting and the customer server
series model were vital components in the advancement of the Internet.
 Windows is an operating system used by everybody.

Prices:-
 Linux can consider as free operating system, free downloaded, distributed with the help of
book, magazines and so on. There are valued versions for Linux additionally; however they
are typically less expensive as compare to windows.
 Unix have different flavors and also have different price structures as indicated by sellers.
 Windows have usually low price.

Conclusion

From the above, we can end up with the discussion that Linux is an illustration of open source
programming advancement and free of charge operating system (OS), Unix is a system that is
extremely main stream in colleges, organizations, big enterprises and so on while Microsoft
Windows is said as progression of graphical interface system created, showcased, and traded by
Microsoft. Linux can usually install on a broad range of PC software and hardware, going from
cellular phones, tablets PCs and video game relieves, to centralized servers and supercomputers
while Unix system is utilized as a part of web servers, workstations and PCs and Windows is a
system used on computer’s desktops, portable workstations, servers and a few phones. Linux and
windows is used by everybody but Unix were produced fundamentally for servers, mainframes and
workstations. Linux and windows have low price while Unix have different price structures as
indicated by sellers.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23
Viva questions

Q1. How would you differentiate UNIX and LINUX? (BT-1/CO-1)

Ans. UNIX originally began as a propriety operating system from Bell Laboratories, which later
spawned into different commercial versions. On the other hand, Linux is free, open source and intended
as a non-propriety operating system for the masses.

Q2. What are the basic components of Linux? (BT-1/CO-1)

Ans. Just like any other typical operating system, Linux has all these components: kernel, shells and
GUIs, system utilities, and application program. What makes Linux advantageous over other operating
system is that every aspect comes with additional features and all codes for these are downloadable for
free.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 3

Write a program to implement FCFS CPU scheduling algorithm.

#include<iostream.h>
#include<conio.h>
voidmain()

{
clrscr();
cout<<"Aastha wadhwa";
cout<<"0808CI211005";

float n,i,j,p[10],q[10],r[10],avgp=0,avgt=0;
cout<<"\n\t no. of process(max=10)::";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\n\t burst time for process "<<i+1<<"::";cin>>p[i];
}
q[0]=0;
for(i=1;i<n;i++)
{
q[i]=q[i-1]+p[i-1];
}
for(i=0;i<n;i++)
{
cout<<"\n\n\tWaitingtimeforprocess"<<i+1<<"::";
cout<<q[i];
avgp=avgp+q[i];
}
float s;
s=avgp/n;
cout<<"\n\tAveragewaitingtime::"<<s;r[0]=p[0];
for(i=1;i<n+1;i++)
{
r[i]=r[i-1]+p[i];
}
for(i=0;i<n;i++)
{
cout<<"\n\n\tTurnaroundtimeforprocess"<<i+1<<"::";
cout<<r[i];
avgt=avgt+r[i];
}
float l;
l=avgt/n;
cout<<"\n\tAveragewaitingtime::"<<l;
getch();
}

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. FCFS is preemptive or non-preemptive algorithm? (BT-1/CO-2)

Ans. FCFS is a non-preemptive algorithm.

Q2. What is convey effect? (BT-1/CO-2)

Ans. small processes wait for the one big process to get off the CPU, these increase the average waiting
time, it is called Convey effect.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 4

Write a program to implement SJF CPU scheduling algorithm.

#include<iostream.h>
#include<conio.h>

intmain()
{
inti,n,p[20],min,k=1,btime=0;
intbt[10],temp,j,at[10],wt[10],tt[10],ta=0,sum=0;
float wavg=0,tavg=0,tsum=0,wsum=0;
clrscr();
cout<<"Aastha Wadhwa";
cout<<"0808CI211005";

cout<<"\nEnter the No. of processes :";cin>>n;


for(i=0;i<n;i++)
{
cout<<"\tEnterthebursttimeofprocess"<<i+1<<":";
cin>>bt[i];
cout<<"Enterthearrivaltimeofprocess"<<i+1<<":";
cin>>at[i];
p[i]=i+1;
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(at[i]<at[j])
{
temp=p[j];
p[j]=p[i];
p[i]=temp;
temp=at[j];
at[j]=at[i];
at[i]=temp;
temp=bt[j];
bt[j]=bt[i];
bt[i]=temp;
}
}
}
for(j=0;j<n;j++)
{
btime=btime+bt[j];
min=bt[k];
for(i=k;i<n;i++)
{
if(btime>=at[i]&&bt[i]<min)
{
temp=p[k];
p[k]=p[i];
p[i]=temp;

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


temp=at[k];
at[k]=at[i];
at[i]=temp;
temp=bt[k];
bt[k]=bt[i];
bt[i]=temp;
}
}
k++;
}
wt[0]=0;
for(i=1;i<n;i++)
{
sum=sum+bt[i-1];
wt[i]=sum-at[i];
wsum=wsum+wt[i];
}
wavg=(wsum/n);
for(i=0;i<n;i++)
{
ta=ta+bt[i];
tt[i]=ta-at[i];
tsum=tsum+tt[i];
}
tavg=(tsum/n);
cout<<"RESULT-";
cout<<"\nProcess\t Burst\t Arrival\t Waiting\t Turn-around";
for(i=0;i<n;i++)
{
cout<<"\np"<<p[i]<<"\t"<<bt[i]<<"\t"<<at[i]<<"\t\t"<<wt[i]<<"\t\t"<<tt[i];
}
cout<<"\n\nAVERAGE WAITING TIME :"<<wavg;cout<<"\nAVERAGETURNAROUNDTIME:"<<tavg;
getch();
return0;
}

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. Which of the four scheduling algorithm gives minimum average waiting time? (BT-1/CO-2)

Ans. Shortest Job First Scheduling

Q2. Is SJF preemptive or not? (BT-1/CO-2)

Ans. SJF can be both preemptive andnon-preemptive. Preemptive SJF is also called Shortest remaining
time first.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 5

Write a program to implement Priority CPU scheduling algorithm

#include<iostream.h>
#include<conio.h>
#include<string.h>

voidmain()
{
intet[20],at[10],n,i,j,temp,p[10],st[10],ft[10],wt[10],ta[10],totwt=0,totta=0;
float awt,ata;
charpn[10][10],t[10];
clrscr();
cout<<"Aastha Wadhwa";
cout<<"0808CI211005";

cout<<"Enterthenumberofprocess:";cin>>n;
for(i=0;i<n; i++)
{
cout<<"Enterprocessid,arrivaltime,executiontime&priority:";
cin>>pn[i]>>at[i]>>et[i]>>p[i];
}
for(i=0; i<n; i++)
{
for(j=0;j<n;j++)
{
if(p[i]<p[j])
{
temp=p[i];
p[i]=p[j];
p[j]=temp;
temp=at[i];
at[i]=at[j];
at[j]=temp;
temp=et[i];
et[i]=et[j];
et[j]=temp;
strcpy(t,pn[i]);
strcpy(pn[i],pn[j]);
strcpy(pn[j],t);
}
}
}
for(i=0;i<n;i++)
{
if(i==0)
{
st[i]=at[i];
wt[i]=st[i]-at[i];

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


ft[i]=st[i]+et[i];
ta[i]=ft[i]-at[i];
}else{
st[i]=ft[i-1];
wt[i]=st[i]-at[i];
ft[i]=st[i]+et[i];
ta[i]=ft[i]-at[i];
}
totwt+=wt[i];totta+=ta[i];
}
awt=(float)totwt/n;
ata=(float)totta/n;
cout<<"\nPname\tarrivaltime\texecutiontime\tpriority\twaitingtime\ttatime";
for(i=0;i<n;i++)
{
cout<<"\n"<<pn[i]<<"\t"<<at[i]<<"\t\t"<<et[i]<<"\t\t"<<p[i]<<"\t\t"<<wt[i]<<"\t\t"<<ta[i];
cout<<"\nAveragewaitingtimeis:"<<awt;
cout<<"\nAverageturnaroundtimeis:"<<ata;
}
getch();
}

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. What is starvation? (BT-1/CO-2)

Ans. A process that is ready to run but lacking the CPU can be considered blocked waiting for the CPU.
A priority scheduling algorithm can leave some low priority processes waiting indefinitely for the CPU,
this is called starvation.

Q2. What is priority? (BT-1/CO-2)

Ans. Priorities are generally some fixed ranges of numbers such as 0 to 4095 etc. priorities can be
defined either externally or internally by operating system.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 6

Write a program to implement Round Robin CPU scheduling algorithm

#include<iostream.h>
#include<conio.h>
intmain()
{
intcount,j,n,time,remain,flag=0,time_quantum;
intwait_time=0,turnaround_time=0,at[10],bt[10],rt[10];cout<<"EnterTotalProcess:\t";
cout<<"Aastha wadhwa";
cout<<"0808CI211005";

cin>>n;
remain=n;
for(count=0;count<n;count++)
{
cout<<"EnterArrivalTimeandBurstTimeforProcessProcessNumber"<<count+1<<":";
cin>>at[count];
cin>>bt[count];
rt[count]=bt[count];
}
cout<<"Enter Time Quantum:\t";
cin>>time_quantum;
cout<<"\n\nProcess\t|Turnaround Time|Waiting Time\n\n";
for(time=0,count=0;remain!=0;)
{
if(rt[count]<=time_quantum&&rt[count]>0)

{
time+=rt[count];rt[count]=0;flag=1;
}
else if(rt[count]>0)
{
rt[count]-=time_quantum;time+=time_quantum;
}
if(rt[count]==0&&flag==1)
{
remain--;
cout<<"P["<<count+1<<"]\t|\t"<<time-at[count]<<"\t|\t"<<time-at[count]-bt[count]<<"\n";
wait_time+=time-at[count]-bt[count];
turnaround_time+=time-at[count];
flag=0;
}
if(count==n-1)count=0;
else if(at[count+1]<=time)count++;
else
count=0; }
cout<<"\nAverage Waiting Time= "<<wait_time*1.0/n<<"\n";
cout<<"Avg Turnaround Time = "<<turnaround_time*1.0/n;getch();

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


return 0;
}

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. Why round robin scheduling is preferred over SJF scheduling? (BT-1/CO-2)

Ans. Round-robin scheduling is simple, easy to implement, and starvation-free.

Q2. What is time quantum? (BT-1/CO-2)

Ans. A small unit of time defined by operating system to execute each process using RR scheduling.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 7

Write a program to implement Banker’s algorithms

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. What are the Coffman’s conditions for deadlock? (BT-1/CO-2)

Ans. Mutual Exclusion: There is s resource that cannot be shared.

Hold and Wait: A process is holding at least one resource and waiting for another resource which is with
some other process.

No Preemption: The operating system is not allowed to take a resource back from a process until process
gives it back.

Circular Wait: A set of processes are waiting for each other in circular form.

Q2. What is resource allocation graph? (BT-1/CO-2)

Ans. A resource allocation graph tracks which resources held by which process and which process is
waiting for a resource of a particular type. It is very powerful and simple tool to illustrate how
interacting processes can deadlock

Q3. What is safe state? (BT-1/CO-2)

Ans. a state is safe if there exists a safe sequence of processes {P0, P1, P2, ..., PN } such that all of the
resource requests for Pi can be granted using the resources currently allocated to Pi and all processes Pj
where j < i.

Q4. What is deadlock? (BT-1/CO-2)

Ans. Deadlock is a situation when two or more processes wait for each other to finish and none of them
ever finish.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 8

Program for simulate memory allocation strategies (First fit, best fit, Worst fit)

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. How would you list the advantage and disadvantage of First Fit strategy? (BT-3/CO-3)

Ans.Advantage

 Fastest algorithm because it searches as little as possible.

Disadvantage

 The remaining unused memory areas left after allocation become waste if it is too smaller. Thus,
request for larger memory requirement cannot be accomplished.

Q2. How would you list the advantage and disadvantage of Best Fit strategy? (BT-3/CO-3)

Ans.Advantage

 Memory utilization is much better than first fit as it searches the smallest free partition first
available.

Disadvantage

 It is slower and may even tend to fill up memory with tiny useless holes.

Q 3. How would you list the advantage and disadvantage of Worst Fit strategy? (BT-3/CO-3)

Ans.Advantage

 Reduces the rate of production of small gaps.

Disadvantage

 If a process requiring larger memory arrives at a later stage, then it cannot be accommodated as
the largest hole is already split and occupied.

Q4. How would you explain fragmentation? (BT-3/CO-3)

Ans. Fragmentation occurs in a dynamic memory allocation system when many of the free blocks are
too small to satisfy any request.

External Fragmentation: External Fragmentation happens when a dynamic memory allocation algorithm

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


allocates some memory, and a small piece is left over that cannot be effectively used. If too much
external fragmentation occurs, the amount of usable memory is drastically reduced. Total memory space
exists to satisfy a request, but it is not contiguous.

Internal Fragmentation: Internal fragmentation is the space wasted inside of allocated memory blocks
because of restriction on the allowed sizes of allocated blocks. Allocated memory may be slightly
larger than requested memory; this size difference is memory internal to a partition, but not being used.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 9

Write a program to implement various page replacement algorithms

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. What is page fault? (BT-1/CO-3)

Ans. Page fault occurs when a requested page is mapped in virtual address space but not present in
memory.

Q3. What is Belady’s anomaly. (BT-1/CO-3)

Ans. In FCFS page replacement algorithm if we increase the number of frames we expect tat the page
fault would decrease but it is not the case always. As we increase number of frames page fault also
increases this unexpected result is called Belady’s anomaly.

Q3. What is global and local page replacement? (BT-1/CO-3)

Ans. If a process replaces only its own page than it is known as local page replacement and if a process
replaces the pages of itself as well as other processes than it is known as global page replacement

Q4. What is page cannibalizing? (BT-1/CO-3)

Ans. Page swapping or page replacements are called page cannibalizing.

Q5. What is Dispatcher? (BT-1/CO-3)

Ans. Dispatcher module gives control of the CPU to the process selected by the short-term

scheduler: this involves: Switching context, switching to user mode, jumping to the proper location in
the user program to restart that program, dispatch latency – time it takes for the dispatcher to stop one
process and start another running.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 10

Write a program to implement various Disk scheduling Algorithms

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1 What is relative path and absolute path? (BT-1/CO-5)

Ans. Absolute path-- Exact path from root directory.

Relative path-- Relative to the current path.

Q2. What is seek time? (BT-1/CO-5)

Ans. Seek time is the time for the disk arm to move the heads to the cylinder containing the desired
sector.

Q3. What is Transfer time? (BT-1/CO-5)

Ans. Transfer Time: Transfer time is the time to transfer the data. It depends on the rotating speed of the
disk and number of bytes to be transferred.

Q4. What is Rotational Latency? (BT-1/CO-5)

Ans. Rotational Latency: Rotational Latency is the time taken by the desired sector of disk to rotate into
a position so that it can access the read/write heads. So the disk scheduling algorithm that gives
minimum rotational latency is better.

Q4. What is disk bandwidth? (BT-1/CO-5)

Ans. Disk bandwidth is the total number of bytes transferred, divided by the total time between the first
request for service and the completion of the last transfer.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Experiment No. 11

Write a program to implement Highest Response Ratio Next CPU Scheduling algorithm

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23


Viva questions

Q1. What is HRRN scheduling explain in short? (BT-1)

Ans. HRRN scheduling is done on the basis of an extra parameter called Response Ratio. A Response
Ratio is calculated for each of the available jobs and the job with the highest response ratio is given
priority over others.

Response Ratio is calculated by the following formula: - Response Ration= (W+S)/S

Were,

W= waiting time and S=service time or burst time

Q2. What do you mean by non-preemptive scheduling? name some non-preemptive scheduling
algorithm and preemptive scheduling algorithm? (BT-1)

Ans. The algorithm in which if processor allocated to one process it will not switch to another process
until current process is done with its work. Some non-preemptive algorithms are: -

FCFS HRRN SJF

Some preemptive algorithms are: - PRIORITY

SRTF

ROUND ROBIN

etc.

5th SEM PCC-CSIT503 OPERATING SYSTEM 2022-23

You might also like