Lab Manual Report
Lab Manual Report
INSTITUTEOFENGINEERING&SCIENCECOMP
UTER SCIENCE &
ENGINEERINGDEPARTMENT
LAB MANUAL
(PCC-CSIT503)
OperatingSystem
Name …………………………………………………..
3. PEOs
4. POs
5. COs
8. Index
9. Experiments
To be the fountainhead of novel ideas & innovations in science & technology & persist to be a
foundation of pride for all Indians.
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.
4. To instigate sponsored research and provide consultancy services in technical, educational, and
industrial areas.
Attaining global recognition in computer science and engineering education, research, and training to
meet the growing needs of the industry and society.
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.
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.
6. To motivate students’ perseverance for lifelong learning and to introduce them to professional
ethics and codes of professional practice.
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.
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
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.
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.
PCC-CS503.1State the core concepts of operating system, evolution, and types of operatingsystem.(BT-
1)
5. Students should sign in the LOGIN REGISTER before entering the laboratory.
6. Students should come with observation and record notebook to the laboratory.
9. After completing the laboratory exercise, make sure to SHUTDOWN the system properly.
4. WriteaprogramtoimplementSJFCPUscheduling algorithm
(CO2)
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
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
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.
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.
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
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
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.
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.
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.
#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();
}
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.
#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";
Q1. Which of the four scheduling algorithm gives minimum average waiting time? (BT-1/CO-2)
Ans. SJF can be both preemptive andnon-preemptive. Preemptive SJF is also called Shortest remaining
time first.
#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];
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.
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.
#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();
Q1. Why round robin scheduling is preferred over SJF scheduling? (BT-1/CO-2)
Ans. A small unit of time defined by operating system to execute each process using RR scheduling.
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.
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
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.
Ans. Deadlock is a situation when two or more processes wait for each other to finish and none of them
ever finish.
Program for simulate memory allocation strategies (First fit, best fit, Worst fit)
Q1. How would you list the advantage and disadvantage of First Fit strategy? (BT-3/CO-3)
Ans.Advantage
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
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.
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
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.
Ans. Page fault occurs when a requested page is mapped in virtual address space but not present in
memory.
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.
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
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.
Ans. Seek time is the time for the disk arm to move the heads to the cylinder containing the desired
sector.
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.
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.
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.
Write a program to implement Highest Response Ratio Next CPU Scheduling algorithm
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.
Were,
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: -
SRTF
ROUND ROBIN
etc.