Operating System Module 1 - Notes
OPERATING SYSTEM
MODULE -1
OS OVERVIEW AND SYSTEM
STRUCTURE
DAYANANDA SAGAR UNIVERSITY
DEPARTMENT OF CSE
Mark Distribution –Courses(THEORY)
Course subject
(100 Marks)
CIA
(60 Marks)SEE
(40 Marks)
Passing mark = CIA + SEE = 40Exam Total Converted
CIA 60 60
SEE 100 40Criteria Weightage of Marks
Mid -Semester Examination –I 15
Mid -Semester Examination –II 15
Conduct the
regular
practical lab
and recoding
of the
experiment
with via -voce10
Lab Internal
Practical Test10
Case Study
Report5
OBE(Open Book
Test)5
Total 60 marks 5th SEM CSE 2
CHAPTER 1
INTRODUCTION
TO
OPERATING SYSTEMS
Introduction to Operating Systems
Operating System:
• An Operating system is system software that manages computer hardware and software
resource and
provides common service for computer programs
• Osis acts as interface between user and computer hardware.
• Its supports a computers basic functions, such as Scheduling tasks and controlling
peripherals.
Examples of OS include windows, Linux, mac OS, Ubuntu, Unix etc.
Operating system for mobile devices include Apple ios, Google android
Goals of Operating system:
• Execute user program and make solving user problems easier.
• Make the computer system convenient to use.
• Use the computer hardware in an efficient manner.
• It should be Flexible, reliable, compatible.
Introduction to Operating
Systems( cont…)
•Purpose of Operating System:
To organize and control the hardware and software
so that the computer behaves.
In a flexible way as the user requires.
Components of computer:
WINDOW
•It is a family of operating system.
•Developed and distributed by Microsoft.
•It fully Graphical based interface(GUI) Operating System.
•advantage:
oftware is available.
•Disadvantage:
•Costly.
•Not Secure.
•It needs to reboot periodically.
•Window based software are more cost.
UNIX
•Unix is an operating system which was first developed in the 1960’s.
•It is a stable, multi -user,multi -tasking system for server, desktops and laptops.
•Different cost structure according to vendors.
•Its used for internet server, workstation and PC’s.
•Types of unix:-Sun Solaris,GNU /linux,MacOS .
•Unix has 3 parts:
Kernel.
Shell.
Processes.
•Kernel
The kernel of unix is the hub of the OS.
It allocate time and memory to program.
Handles the file store and communications in response to system calls.
•Shell:
The shell acts as an interface between the user and the kernel .
The shell is command line interpreter(CLI).
•Files and Processes:
File is a collection of data,they are created by users using text editors,
running compilers etc.
Processes is an executing program identified by a unique process
identifiers(PID).
•All files grouped together is called a directory structure.
The top of the hierarchy is traditionally called root(written as a slash).
The full path to the files report
“/home/its/uq1/ee51vn/[Link]”
The path is like tree structure:
Advantage and disadvantage of UNIX
•Advantage:
Unix has largely been used for high end computer workstations and
servers.
It support for online application.
It is very simple and modular design.
•Disadvantage:
its not for everyone.
Unix is largely designed around the text -based command line.
Its support limited software and hardware.
LINUX
•Its Open -source software development and mostly used for server
purpose.
•Its supports many programming language like c,c++,Java,PHP .
•Its can be freely distributed.
•Its developed by Linus Torvalds.
•Its used for Computer, mobile phone, tablet mainframes and super
computers.
Advantage and disadvantage of
LINUX
•Advantage :
formance on workstation and networks.
•Disadvantage:
1. WHAT IS AN OPERATING SYSTEM?
■Aprogram that acts asanintermediary between auser ofa
computer and thecomputer hardware .
■Anoperating system (OS) isacollection ofsoftware thatmanages
computer hardware resources andprovides common services for
computer programs .
■Theoperating system isavital component ofthesystem software
inacomputer system .
13
1. WHAT IS AN OPERATING SYSTEM?
•Anoperating system isasoftware which performs allthebasic
tasks like file management, memory management, process
management, handling input and output, and controlling
peripheral devices such asdisk drives andprinters .
■Operating system goals :
●Execute user programs and make solving user problems
easier.
●Make the computer system convenient to use.
●Use the computer hardware in an efficient manner .
•Examples of OS include windows, Linux, mac OS, Ubuntu, Unix
etc.
•Operating system for mobile devices include Apple ios, Google
android
14
What is an Operating System Used for
151) improving the computer software as well as hardware.
2)Without OS, it became very difficult for any application to be user -friendly.
3)The operating System comes with a large number of device drivers.
4)Each and every application present in the system requires the Operating System.
5)The operating system works as a communication channel between system hardware and
system software.
1. 1 WHY STUDY OS?
•OS is a key part of a computer system
–it is “magic” and we want to understand how
–it has “power” and we want to have the power
• OS is complex –how many procedures does a keystroke
invoke?
–What happens when your running application program
references a pointer having the value 0?
–Real OS is huge and very expensive to build
--win/NT: 8 years, 1000s of people
16
OVERVIEW OF OS
17
2. COMPUTER SYSTEM STRUCTURE
■Computer system can be divided into four components
●Hardware –provides basic computing resources
Ex: CPU, memory, I/O devices
●Operating system -Controls and coordinates use of
hardware among various applications and users
●Application programs –define the ways in which the
system resources are used to solve the computing
problems of the users.
Ex: Word processors, web browsers, database
systems, video games
●Users
Ex: People, machines, other computers18
FOUR COMPONENTS OF A COMPUTER SYSTEM
19
3. WHAT OPERATING SYSTEMS DO
3.1 VIEWS
20The operating system (OS) manages allofthe
software andhardware onthecomputer .Itperforms
basic tasks such asfile, memory and process
management, handling input and output, and
controlling peripheral devices such asdisk drives
andprinters .
3. WHAT OPERATING SYSTEMS DO
21
3.2 OPERATING SYSTEM DEFINITION
•No universally accepted definition
•“Everything a vendor ships when you order an operating system”
is a good approximation
•But varies wildly
•“The one program running at all times on the computer” is the
kernel .
•Everything else is either
•A system program (ships with the operating system) , or
•An application program.
22
3.3 NEED OF OS
■OS as a platform for Application programs
■Managing Input Output Unit
■Consistent User Interface
■Multi -Tasking
23
24
25
4. COMPUTER SYSTEM ORGANIZATION
4.1. COMPUTER SYSTEM OPERATION
4.2. STORAGE STRUCTURE
4.3. I/O STRUCTURE
26
4.1 COMPUTER SYSTEM OPERATION
•One or more CPUs, device controllers connect through
common bus providing access to shared memory
•Concurrent execution of CPUs and devices competing
for memory cycles
27
284.1 COMPUTER SYSTEM OPERATION
AModern general–purpose computer system consists ofone
ormore CPUs andanumber ofdevice controllers connected through a
common busthatprovides access toshared memory .
ge of a specific type of device.
competing for memory cycles.
is provided whose function is to synchronize access to the memory.
294.1 COMPUTER SYSTEM OPERATION
Some important terms :
1)Bootstrap Program :
Theinitial program thatruns when acomputer ispowered uporrebooted .
Itisstored intheROM .
Itmust know how toload theOSandstart executing thatsystem
Itmust locate andload intomemory theOSkernel .
2)Interrupt :
The occurrence ofanevent isusually signaled byanInterrupt from Hardware or
Software .
Hardware may trigger aninterrupt atanttime bysending asignal totheCPU, usually
bytheway ofthesystem bus.
3)System Call(Monitor Call) :
Software may trigger aninterrupt byexecuting aspecial operation called System Call.
•Each device controller isincharge ofaparticular
device [Link] device controller has alocal
buffer .
•CPU moves data from/to main memory to/from
local buffers .
•I/Oisfrom thedevice tolocal buffer ofcontroller .
•Device controller informs CPU thatithasfinished
itsoperation bycausing aninterrupt .
304.1 Computer System Operation
What is Interrupt
31An interrupt is a hardware -generated change of flow within the system. An interrupt
handler deals with the cause of
the interrupt. The control is then returned to the interrupted context and instruction.
Interrupt handling
•The operating system preserves thestate oftheCPU by
storing registers andtheprogram counter .
•Determines which type ofinterrupt hasoccurred :
•Polling
•Vectored interrupt system
•Separate segments ofcode determine what action should be
taken foreach type ofinterrupt .
324.1 Computer System Operation
Common Functions of Interrupts
33Each computer architecture has its own interrupt mechanism, but they all have several
functions in common. Different functions of interrupts area as follows:
1)When an interrupt occurs, the control is transferred to the interrupt service routine.
2)The interrupt service routine is generally accessed through an interrupt vector.
3)The interrupt vector knows where to find the appropriate interrupt service routine for
the current interrupt.
4)The interrupt architecture must save the address of the instruction that has been
interrupted.
5)An interrupt is generally caused by a hardware device such as a device driver
allowing the CPU to know that some data has been read from the device and is
waiting in the local devices buffer.
Common functions ofinterrupts
•Atrap orexception isasoftware -generated interrupt caused either byanerror orauser
request foran
I/Ooperation .
•Anoperating system isinterrupt driven .This means thatifthere arenointerrupts, then
thesystem
willbeidle.
•Theoperating system must preserve thestate oftheCPU bystoring thecontents
oftheregisters and
theprogram counter .
•The Operating system must determine which type ofinterrupt hasoccurred .This
canbedone either
bypolling orbyusing avectored interrupt system .
•Polling isthesymmetric checking ofeach device toseeifitwasthedevice responsible
forgenerating
theinterrupt .
•Iftheoperating system hasavectored interrupt system, then theidentity ofthedevice
andthetype of
interrupt willbeeasily identifiable without checking each device .
•Theoperating system must provide asegment ofCode thatspecifies what action istobetaken
inthe
event ofaninterrupt .There must beacode segment thatisspecific toeach type ofinterrupt .
344.1 Computer System Operation
4.1 COMPUTER SYSTEM OPERATION
[Link] Interrupt Polling
[Link] interrupt, the device notices the
CPU that it requires its [Link], in polling, CPU steadily checks
whether the device needs service.
[Link] interrupt is not a protocol, its a
hardware [Link] it isn’t a hardware mechanism, its a
protocol.
[Link] interrupt, the device is serviced by
interrupt [Link] in polling, the device is serviced by
CPU.
4. Interrupt can take place at any [Link] CPU steadily checks the device at
regular or proper interval.
[Link] interrupt, interrupt request line is
used as indication for indicating that
device requires [Link] in polling, Command ready bit is used as
indication for indicating that device requires
servicing.
[Link] interrupts, processor is simply
disturbed once any device interrupts [Link] the opposite hand, in polling, processor
waste countless processor cycles by repeatedly
checking the command -ready little bit of each
device.35
INTERRUPT TIMELINE
364.1Computer System Operation
4.2 Storage Structure
•Main memory –only large storage media that the CPU can access
directly
•Random access
•Typically volatile
•Secondary storage –extension of main memory that provides large
nonvolatile storage capacity.
•Hard disks –rigid metal or glass platters covered with magnetic
recording material
•Disk surface is logically divided into tracks , which are subdivided
into sectors
•The disk controller determines the logical interaction between the
device and the computer
•Solid -state disks –faster than hard disks, nonvolatile
•Various technologies
•Becoming more popular 37
4.2 Storage Structure
•Basically we want the programs and data to reside in main memory
permanently. This arrangement is usually not possible for the following
two reasons:
•1. Main memory is usually too small to store all needed programs and
data permanently.
•2. Main memory is a volatile storage device that loses its contents when
power is turned off or otherwise lost.
There are two types of storage devices: -
•volatile storage device –it loses its contents when the power of the
device is removed. Ex:RAM , Cache, Registers
•Non-volatile storage device –it does not loses its contents when the
power is removed. Ex: SSD, HDD38
STORAGE DEVICE HIERARCHY
394.2 Storage Structure
40
Storage Device Hierarchy
•The wide variety of storage systems in a computer system can be
organized in a hierarchy according to speed and cost.
•The higher levels areexpensive, but they are [Link]
move down thehierarchy, thecost perbitgenerally decreases,
whereas theaccess time generally increases .
•The storage systems above the electronic disk are volatile ,
whereas those below are nonvolatile
414.2 Storage Structure
Storage Hierarchy
•Storage systems organized in hierarchy
•Speed
•Cost
•Volatility
•Caching –copying information into faster storage system; main
memory can be viewed as a cache for secondary storage
•Device driver for each device controller to manage I/O
•Provides uniform interface between controller and kernel
424. 2 Storage Structure
4.2 Storage Structure
CACHING
•Inasystem accessing data from primary memory (RAM) isfaster than
accessing data from secondary memory (disk) .
•Caching acts asthelocal store forthedata andretrieving thedata from
thislocal ortemporary storage iseasier andfaster than retrieving itfrom the
database .
•Consider itasashort -term memory thathaslimited space butisfaster and
contains themost recently accessed items .
•Soifyouneed torely onacertain piece ofdata often then cache thedata
andretrieve itfaster from thememory rather than thedisk.
43
4.2 Storage Structure
Ex:
•Web browsers like safari, firefox and chrome use browser caching to
improve theperformance offrequently accessed webpages .When auser
visits awebpage, therequested files arestored inacache forthatbrowser in
theuser's computing storage .
•Toretrieve apreviously accessed page, thebrowser gets most ofthefiles it
needs from thecache rather than having them resent from theweb server .
This approach iscalled read cache .The browser canread data from the
browser cache faster than itcanreread thefiles from thewebpage .44
4.2 Storage Structure
•The storage systems above theelectronic disk are volatile,
where asthose below arenon-volatile .
•Anelectronic disk canbeeither designed tobeeither volatile
ornon-volatile .
•During normal operation, theelectronic disk stores data ina
large DRAM array, which isvolatile .
•But many electronic disk devices contain ahidden magnetic
hard disk andabattery forbackup power .Ifexternal power is
interrupted, theelectronic disk controller copies thedata from
RAM tothemagnetic disk.
•When external power isrestored, thecontroller copies thedata
back intotheRAM .45
4.2 Storage Structure
•HDDs aretraditional storage devices with spinning platters that read
and write [Link] arecheaper, have more storage capacity, and
offer easier data recovery ifdamaged .
•SSDs usenewer technology that stores data oninstantly accessible
memory chips .SSDs arefaster, quieter, smaller, consume lessenergy,
andmore durable .
•The main difference between asolid state drive (SSD) andahard disk
drive (HDD) ishow data isstored andaccessed .
•HDDs usemechanical spinning disks and amoving read/write head
toaccess data, while SSDs usememory chips
46
4.3 I/O STRUCTURE
47How A Modern Computer Works
I/O STRUCTURE
48•Storage isonly oneofmany types ofI/Odevices within acomputer .
•Alarge portion ofOScode isdedicated tomanaging I/O.
•Because ofitsimportance tothereliability andperformance ofasystem andthevarying
nature ofthedevices .
•Ageneral -purpose computer system consists ofCPUs andMultiple device controllers that
areconnected through acommon bus.
•Each device controller isincharge ofaspecific type ofdevice .
1)Local Buffer Storage .
2)SetofSpecial Purpose Registers .
•Typically, OShave adevice driver foreach device controller .
•This device driver understands thedevice controller andpresents auniform interface tothe
device totherestoftheOS.
4.3 I/O STRUCTURE
•Adevice controller maintains some local buffer storage and a
setofspecial -purpose registers .
•The device controller isresponsible formoving the data
between theperipheral devices thatitcontrols anditslocal buffer
storage .
•Typically, operating systems have adevice driver foreach
device controller .
•Driver understands thedevice controller andpresents auniform
interface tothedevice totherestoftheoperating system .
49
4.3 I/O STRUCTURE
50
4.3 I/O STRUCTURE
•Tostart anI/Ooperation, thedevice driver loads theappropriate
registers within thedevice controller .
•Thedevice controller ,inturn, examines thecontents ofthese registers
todetermine what action totake (such as"read acharacter from the
keyboard") -
•Thecontroller starts thetransfer ofdata from thedevice toitslocal
buffer .
•Once thetransfer ofdata iscomplete, thedevice controller informs the
device driver viaaninterrupt thatithasfinished itsoperation .
•Thedevice driver then returns control totheoperating system, possibly
returning thedata orapointer tothedata iftheoperation was aread.
Forother operations, thedevice driver returns status information .51
4.3 I/O STRUCTURE
Theform ofinterrupt driven I/Oisfineformoving small amount ofdata but
canproduce high overhead when used forbulk data movement .
Tosolve thisproblem weuseDMA
Direct Memory Access Structure
•Used for high -speed I/O devices able to transmit information at close to
memory speeds.
•Device controller transfers blocks of data from buffer storage directly to
main memory without CPU intervention.
•Only one interrupt is generated per block, rather than the one interrupt per
byte.
52
5. COMPUTER SYSTEM
ARCHITECTURE
5.1. SINGLE PROCESSOR SYSTEM
5.2. MULTI PROCESSOR SYSTEM
5.3. CLUSTERED SYSTEM
53
5.1 SINGLE PROCESSOR SYSTEM
•On a single -processor system, there is one main CPU capable of
executing a general -purpose instruction set, including instructions from
user processes.
•Soonly oneprocess canbeexecuted atatime andthen theprocess is
selected from theready queue .Most general purpose computers contain
thesingle processor systems asthey arecommonly inuse.
54
5.2 MULTI -PROCESSOR SYSTEM
In,multiprocessor systems (also known asparallel systems or
tightly coupled systems) aregrowing inimportance .
Such systems have two ormore processors inclose
communication, sharing thecomputer bus and sometimes the
clock, memory, andperipheral devices .
Advantages include:
[Link] throughput
[Link] of scale
[Link] reliability
Two types:
[Link] Multiprocessing –each processor is
assigned aspecific task.
[Link] Multiprocessing –each processor performs
alltasks55
5.2 MULTI -PROCESSOR SYSTEM
56
5.3 CLUSTERED SYSTEMS
•Like multiprocessor systems, butmultiple systems working together
•Usually sharing storage viaastorage -area network (SAN)
•Provides ahigh -availability service which survives failures
•Asymmetric clustering hasonemachine inhot-standby mode
•Symmetric clustering hasmultiple nodes running applications,
monitoring each other
•Some clusters areforhigh -performance computing (HPC)
•Applications must bewritten touseparallelization
•Some have distributed lock manager (DLM )toavoid conflicting
operations .Incluster systems toavoid file sharing conflicts, the
distributed systems must provide theaccess control andfilelocking .
-This ensures thatnoconflicting operations occur inthesystem .
57
5.3 CLUSTERED SYSTEMS
•Cluster operating systems are a combination
ofsoftware andhardware clusters .
•Hardware clusters aidinthesharing ofhigh-performance disks among all
computer systems, while software clusters give abetter environment forall
systems tooperate .
•Acluster system consists ofvarious nodes, each ofwhich contains its
cluster software .The cluster software isinstalled oneach node inthe
clustered system, anditmonitors thecluster system andensures that itis
operating properly .
•Ifoneoftheclustered system's nodes fails, theother nodes take over its
storage andresources andtrytorestart .
•Cluster components aregenerally linked viafastarea network .
58
5.3 CLUSTERED SYSTEMS
59
ASYMMETRIC CLUSTERING
•Inthissystem, oneofthenodes intheclustered system isinhotstandby
mode andalltheothers runtherequired applications .The hotstandby
mode isafailsafe inwhich ahotstandby node ispartofthesystem .the
hotstandby node continuously monitors theserver andifitfails, thehot
standby node takes itsplace
60
ASYMMETRIC CLUSTERING
•There isamaster node inasymmetric clustering that directs allthe
slaves nodes toperform thetasks required .The requests aredelegated
bythemaster node .
•Adistributed cache isused inasymmetric clustering toimprove the
performance ofthesystem .
•Resources such asmemory, peripheral devices [Link] between
thenodes oftheasymmetric clustering system atboot time.
61
Symmetric clustering
•Insymmetric clustering system twoormore nodes allrunapplications
aswell asmonitor each other .This ismore efficient than asymmetric
system asituses allthehardware anddoesn't keep anode merely asa
hotstandby .
62
CLUSTERED SYSTEMS
•The benefits of clustered system are:
[Link] performance
[Link] fault tolerance
[Link] scalability
•Thelimitations of clustered system are:
[Link] to implement
[Link] establishment, monitoring, and maintenance is complex
63
6 .OPERATING SYSTEM STRUCTURE
[Link]
[Link] (multitasking)
64
6. OPERATING SYSTEM STRUCTURE
6.1. Multiprogramming
•Isanability ofanoperating system that executes more than one
program using asingle processor machine .
•When aprogram isbeing performed, itisknown asa"task",
"process" ,and"job“ .
•More than onetask orprogram orjobs arepresent inside themain
memory atonepoint oftime.
•The OScould pick andstart theexecution ofoneofthejobs in
memory, whenever thejobs does notneed CPU thatmeans thejob
isworking with I/O.
•Atthat time theCPU [Link] OSswitches toanother jobin
memory and CPU executes aportion ofittillthejobissues a
request forI/Oandsoon.65
6. OPERATING SYSTEM STRUCTURE
[Link] ofMultiprogramming
[Link] isutilized most ofthetime andrarely becomes idleunless
there arenojobs toexecute .
[Link] system isfast because allthejobs run parallel amongst
themselves .
[Link] thatwould require CPU forashort duration arefinished earlier
incomparison tothose with long CPU requirement time.
[Link] operating systems support multiple users onthe
computer system .
[Link] utilization isefficient andeven .
[Link] time required toexecute ajobreduced .
[Link] operating systems aregood atdealing with
applications inwhich multiple jobs aretobeexecuted .66
6. OPERATING SYSTEM STRUCTURE
[Link] ofMultiprogramming
[Link], processes requiring long CPU times have towait forother jobs
(usually relatively shorter jobs) tofinish .
[Link]'s not easy keeping track ofalarge number ofprocesses in
multiprogramming .
[Link] operating systems have touseCPU scheduling .
[Link] management should bevery efficient .
[Link] aprogram executes, there cannot beanyinteraction between itand
theuser.
67
Memory layout for multiprogrammed system
68
Multi Programming System
69
6. OPERATING SYSTEM STRUCTURE
[Link] (multitasking )islogical extension inwhich CPU
switches jobs sofrequently that users caninteract with each job
while itisrunning, creating interactive computing .
•Itallows theuser toperform more than onetaskatatime, each task
getting thesame amount oftime toexecute .Hence, thename time
sharing [Link], itisanextension ofmultiprogramming
systems .
•Multiprogramming -theobjective istomaximize processor use,
•Time -sharing systems -theobjective istominimize response time .
70
6.2 TIME SHARING SYSTEM
71
6. 2 TIME SHARING SYSTEM
•Time sharing requires aninteractive (orhands -on)computer
system ,which provides direct communication between theuser
andthesystem .
•The user gives instructions totheoperating system ortoa
program directly, using ainput device such asakeyboard ora
mouse, and waits forimmediate results onanoutput device .
Accordingly, theresponse time should beshort —typically less
than onesecond .
72
TIME SHARING SYSTEM
•Itisthedivision ofCPU time foreach process when more than onetask
aregiven bytheuser.
•Ashort duration oftime ischosen foreach process .Moreover, thistime
duration isvery small intheorder of10-100 milliseconds .This time
duration isknown astime slot, time slice, orquantum .
•Suppose three processes namely, p1,p2,and p3arerunning onthe
system .Now, suppose thatthequantum is4nanoseconds (ns).Now, they
willexecute inthefollowing manner .
•Process p1willexecute for4ns,assoon asitgets over, process p2starts
executing foraduration [Link], when p2gets complete process
P3executes [Link] process continues tillalltheprocesses gets
complete .
•Inthis way, only one process runs atatime but, the switching
between theprocesses isvery fast.
•Hence, theuser feels that alltheprocesses arerunning atthesame
time .73
6. 2 TIME SHARING SYSTEM
Advantages :
•Response time of CPU reduces.
•Idle time of CPU reduces.
•Each task/process gets an equal time slot to execute.
•Disadvantages:
•Problem of reliability.
•Question of security and integrity of user programs and
data.
•Problem of data communication.
74
•Time -sharing and multiprogramming require several jobs to be kept
simultaneously in memory.
•Since in general main memory is too small to accommodate all jobs,
the jobs are kept initially on the disk in the job pool. This pool consists
of all processes residing on disk awaiting allocation of main memory.
•If several jobs are ready to be brought into memory, and if there is not
enough room for all of them, then the system must choose among them.
Making this decision is job scheduling .
•When the operating system selects a job from the job pool, it loads that
job into memory for execution. Having several programs in memory at
the same time requires some fo rm of memory management.
•In addition, if several jobs are ready to run at the same time, the system
must choose among them. Making this decision is CPU scheduling
75
7. OPERATING -SYSTEM OPERATIONS
•Interrupt driven (hardware and software)
•Hardware interrupt by one of the devices
•Software interrupt ( exception or trap):
•Software error (e.g., Division by zero)
•Request for operating system service
•Other process problems include infinite loop, processes
modifying each other or the operating system
OPERATIONS:
1. DUAL MODE
2. TIMER
76
7. OPERATING -SYSTEM OPERATIONS
7.1 DUAL MODE
•Dual -mode operation allows OS to protect itself and other system components
•User mode and kernel mode
•Abit,called themode bit,isadded tothehardware ofthecomputer to
indicate thecurrent mode :kernel (0)oruser (1).With themode bit,
weareable todistinguish between atask thatisexecuted onbehalf of
theoperating system andonethatisexecuted onbehalf oftheuser.
•When thecomputer system isexecuting onbehalf ofauser application,
thesystem isinuser mode .
•However ,when auser application requests aservice from theoperating
system (viaaSystem call), itmust transition from user tokernel mode
tofulfill therequest .77
7. OPERATING -SYSTEM OPERATIONS
7.1 DUAL MODE
•Atsystem boot time ,thehardware starts inkernel mode .The
operating system isthen loaded and starts user applications inuser
mode .
•Whenever atrap orinterrupt occurs, thehardware switches from user
mode tokernel mode (that is,changes thestate ofthemode bitto0).
Thus, whenever theoperating system gains control ofthecomputer, itis
inkernel mode .
•Thesystem always switches touser mode (bysetting themode bitto1)
before passing control toauser program .
•The dual mode ofoperation provides uswith themeans forprotecting
theoperating system from errant users
78
7. OPERATING -SYSTEM OPERATIONS
7.1 DUAL MODE
79A system call is a
programmatic way fora
program to request a
service from theoperating
system kernel .
7. OPERATING -SYSTEM OPERATIONS
7.2 TIMER
•Wemust prevent auser program from getting stuck inan
infinite loop ornot calling system services and never
returning control totheoperating system
•Atimer canbesettointerrupt thecomputer after aspecified
period .The period may befixed (forexample, 1/60second)
orvariable (forexample, from 1millisecond to1second) .
•Avariable timer isgenerally implemented byafixed -rate
clock andacounter .Theoperating system setsthecounter .
80
7. OPERATING -SYSTEM OPERATIONS
7.2 TIMER
How wecanusethetimer toprevent auser program from running
toolong?
•Asimple technique istoinitialize acounter with theamount oftime
that aprogram isallowed torun.
•Aprogram with a7-minute time limit, forexample, would have its
counter initialized [Link] second, thetimer interrupts and the
counter isdecremented by1.
•Aslong asthecounter ispositive ,control isreturned totheuser
program .
•When thecounter becomes negative ,theoperating system terminates
theprogram forexceeding theassigned time limit.81
8. PROCESS MANAGEMENT
•A process is a program in execution. It is a unit of work within the system.
•Program is a passive entity , process is an active entity .
•Process needs resources to accomplish its task
•CPU, memory, I/O, files
•Initialization data
•Process termination requires reclaim of any reusable resources.
•Single -threaded process has one program counter specifying location of next
instruction to execute.
•Process executes instructions sequentially, one at a time, until completion
•Multi -threaded process has one program counter per thread
•Typically system has many processes, some user, some operating system running
concurrently on one or more CPUs.
•Concurrency by multiplexing the CPUs among the processes / threads82
8. PROCESS MANAGEMENT
The operating system is responsible for the following activities in
connection with process management:
•Creating and deleting both user and system processes
•Suspending and resuming processes
•Providing mechanisms for process synchronization
•Providing mechanisms for process communication
•Providing mechanisms for deadlock handling
83
9. MEMORY MANAGEMENT
•To execute a program all (or part) of the instructions must be in memory
•All (or part) of the data that is needed by the program must be in
memory.
•Memory management determines what is in memory and when
•Optimizing CPU utilization and computer response to users
•Memory management activities
•Keeping track of which parts of memory are currently being used
and by whom
•Deciding which processes (or parts thereof) and data to move into
and out of memory
•Allocating and de-allocating memory space as needed 84
10. STORAGE MANAGEMENT
10.1 FILE SYSTEM MANAGEMENT
10.2 MASS STORAGE MANAGEMENT
10.3 CACHING
10.4 I/O SYSTEMS
85
10. STORAGE MANAGEMENT
10.1. File -system management
•Files usually organized into directories
•Access control on most systems to determine who can access what
•OS activities include
•Creating and deleting files and directories
•Primitives to manipulate files and directories
•Mapping files onto secondary storage
•Backup files onto stable (non -volatile) storage media
86
10. STORAGE MANAGEMENT
10.2. MASS STORAGE MANAGEMENT :
Usually disks used to store data that does not fit in main memory or data
that must be kept for a “long” period of time
•Proper management is of central importance
•Entire speed of computer operation hinges on disk subsystem and its
algorithms
•OS activities
•Free-space management
•Storage allocation
•Disk scheduling
•Some storage need not be fast
•Tertiary storage includes optical storage, magnetic tape
•Still must be managed –by OS or applications
•Varies between WORM (write -once, read -many -times) and RW
(read -write)87
10. STORAGE MANAGEMENT
[Link] isanimportant principle ofcomputer systems .
Information isnormally kept insome storage system (such as
main memory) .
•Asitisused, itiscopied intoafaster storage system —the
cache —onatemporary basis .
•When weneed aparticular piece ofinformation, wefirst
check whether itisinthecache .
•Ifitis,weusetheinformation directly from thecache ;ifit
isnot, weusetheinformation from thesource, putting a
copy inthecache under theassumption thatwewillneed it
again soon .
88
10. STORAGE MANAGEMENT
10.3. Caching
Performance of Various Levels of Storage
89
10. STORAGE MANAGEMENT
10.3. Caching
In a hierarchical storage structure, the same data may appear in different levels of
the storage system.
•For example, suppose that an integer A that is to be incremented by 1 is located
in file B, and file B resides on magnetic disk.
•The increment operation proceeds by first issuing an I/O operation to copy the
disk block on which A resides to main memory.
•This operation is followed by copying A to the cache and to an internal register.
Thus, the copy of A appears in several places: on the magnetic disk, in main
memory, in the cache, and in an internal register .
•Once the increment takes place in the internal register, the value of A differs in
the various storage systems. The value of A becomes the same only after the new
value of A is written from the internal register back to the magnetic disk.
90
10. STORAGE MANAGEMENT
10.3. Caching
Inacomputing environment where only oneprocess executes ata
time, thisarrangement poses nodifficulties, since anaccess tointeger A
willalways betothecopy atthehighest level ofthehierarchy .
However ,inamultitasking environment ,where theCPU is
switched back andforth among various processes, extreme care must be
taken toensure that, ifseveral processes wish toaccess A,then each of
these processes willobtain themost recently updated value ofA.
91
10. STORAGE MANAGEMENT
[Link]
•Thesituation becomes more complicated inamultiprocessor environment where,
inaddition tomaintaining internal registers, each oftheCPUs also contains alocal
cache .
•Insuch anenvironment, acopy ofAmay exist simultaneously inseveral caches .
Since thevarious CPUs canallexecute concurrently, wemust make sure thatan
update tothevalue ofAinonecache isimmediately reflected inallother caches
where Aresides .
•This situation iscalled cache coherency, and itisusually ahardware problem
(handled below theoperating -system level ).
•Inadistributed environment, thesituation becomes even more complex .
•Inthisenvironment, several copies (orreplicas) ofthesame filecanbekept on
different computers thataredistributed inspace .
•Since thevarious replicas may beaccessed and updated concurrently, some
distributed systems ensure that, when areplica isupdated inoneplace, allother
replicas arebrought uptodate assoon aspossible .92
10. STORAGE MANAGEMENT
10.4 I/O SYSTEMS:
•One purpose of OS is to hide peculiarities of hardware devices from the
user
•I/O subsystem responsible for
•Memory management of I/O including buffering (storing data
temporarily while it is being transferred), caching (storing parts of data
in faster storage for performance), spooling (the overlapping of output
of one job with input of other jobs)
•General device -driver interface
•Drivers for specific hardware devices
93
11. PROTECTION AND SECURITY
•Protection –any mechanism for controlling access of processes or
users to resources defined by the OS.
•Security –defense of the system against internal and external attacks
•Huge range, including denial -of-service, worms, viruses, identity
theft, theft of service
•Systems generally first distinguish among users, to determine who can
do what
•User identities ( user ids , security ids) include name and associated
number, one per user.
•User ID then associated with all files, processes of that user to
determine access control
•Group identifier ( group ID ) allows set of users to be defined and
controls managed, then also associated with each process, file.
•Privilege escalation allows user to change to effective ID with
more rights94
12. DISTRIBUTED SYSTEMS
•Adistributed system isacollection ofphysically separate, possibly
heterogeneous computer systems that arenetworked toprovide theusers with
access tothevarious resources thatthesystem maintains .
•Access toashared resource increases computation speed, functionality, data
availability, andreliability .
•Anetwork, inthesimplest terms, isacommunication path between twoormore
systems .
•Distributed systems depend onnetworking fortheir functionality .
•Networks vary bytheprotocols used, thedistances between nodes, and the
transport media .TCP/IP isthemost common network protocol, although ATM
andother protocols areinwidespread use.
•Likewise, operating system support ofprotocols varies .Most operating systems
support TCP/IP, including thewindows and UNIX operating systems .Some
systems support proprietary protocols tosuittheir needs95
12. DISTRIBUTED SYSTEMS
Networks arecharacterized based onthedistances between their nodes .
▪Alocal -area network (LAN) connects computers within aroom, afloor, ora
building .
▪Awide -area network (WAN) usually links buildings, cities, orcountries .A
global company may have aWAN toconnect itsoffices worldwide .These
networks may runoneprotocol orseveral protocols .
▪Ametropolitan -area network (MAN) could link buildings within acity.
Bluetooth and802.11devices usewireless technology tocommunicate over a
distance ofseveral feet, inessence creating asmall -area network such as
might befound inahome .
Anetwork operating system isanoperating system that provides features
such asfilesharing across thenetwork andthat includes acommunication
scheme that allows different processes ondifferent computers toexchange
messages .
96
13. COMPUTING ENVIRONMENT
13.1 TRADITIONAL COMPUTING
13.2 CLIENT SERVER COMPUTING
13.3 PEER TO PEER COMPUTING
13.4 WEB BASED COMPUTING
97
13. COMPUTING ENVIRONMENT
13.1 Traditional Computing
•Stand -alone general purpose machines
•But blurred as most systems interconnect with others (i.e., The internet)
•Portals provide web access to internal systems
•Network computers (thin clients ) are like web terminals
•Mobile computers interconnect via wireless networks
•Networking becoming ubiquitous –even home systems use firewalls to protect
home computers from internet attacks
98
13. COMPUTING ENVIRONMENT
13.2. CLIENT -SERVER COMPUTING
Inclient server computing, theclients requests aresource and
theserver provides thatresource .
Aserver may serve multiple clients atthesame time while a
client isincontact with only oneserver .
Both the client and server usually communicate via a
computer network butsometimes they may reside inthesame
system .
99
13. COMPUTING ENVIRONMENT
•Another model of distributed system
•P2P does not distinguish clients and servers
•Instead all nodes are considered peers
•May each act as client, server or both
•Node must join P2P network
•Registers its service with central lookup
service on network, or
•Broadcast request for service and respond to
requests for service via discovery protocol
10013.3 Peer -Peer Computing
13. COMPUTING ENVIRONMENT
•Web -based computing isanenvironment that consists ofultra-thin
clients networked over theinternet orintranet .
•Applications inthis environment consist ofcode onthe servers
distributed tothin clients containing abrowser, such asnetscape
communicator orinternet explorer ;thebrowser completely defines the
user interface .
•The implementation ofweb-based computing hasgiven rise tonew
categories ofdevices, such asload balancers, which distribute network
connections among apool ofsimilar servers .
•Operating systems likewindows 95,which acted asweb clients, have
evolved into linux andwindows XP, which canactasweb servers as
well asclients10113.4. Web Based Computing
102
14. OS SERVICES
14.1. USER INTERFACE .
•Almost alloperating systems have auser interface (UI).
•This interface cantake several forms .One isacommand -lineinterface
(CLI), which uses textcommands andamethod forentering them (say, a
program toallow entering andediting ofcommands) .
•Another isabatch interface, inwhich commands and directives to
control those commands areentered into files, and those files are
executed .
•Most commonly/ agraphical user interface (GUI) [Link], the
interface isawindow system with apointing device todirect I/O,choose
from menus, and make selections and akeyboard toenter [Link]
systems provide twoorallthree ofthese variations .
14. OS SERVICES
[Link] execution .
The system must beable toload aprogram into memory andtorunthat
program .
The program must beable toend itsexecution, either normally or
abnormally (indicating error) .
14.3.I/Ooperations
Arunning program may require I/O, which may involve afileoranI/O
device .
Forspecific devices, special functions may bedesired (such asrecording to
aCDorDVD drive ).
For efficiency and protection, users usually cannot control I/Odevices
directly .Therefore, theoperating system must provide ameans todoI/O..
14. OS SERVICES
[Link]-system manipulation .
•Obviously, programs need toread andwrite files anddirectories .
•They alsoneed tocreate anddelete them byname, search foragiven file,
andlistfileinformation .
•Finally, some programs include permissions management toallow or
deny access tofiles ordirectories based onfileownership .
[Link] .
•Communication may occur between processes thatareexecuting onthe
same computer orbetween processes that areexecuting ondifferent
computer systems tiedtogether byacomputer network .
•Communications may beimplemented viashared memory orthrough
message passing ,inwhich packets ofinformation aremoved between
processes bytheoperating system ..
14. OS SERVICES
[Link] detection .
•Errors may occur intheCPU andmemory hardware (such as
amemory error orapower failure), inI/Odevices (such asa
parity error ontape, aconnection failure onanetwork, or
lack ofpaper intheprinter), andintheuser program (such as
anarithmetic overflow, anattempt toaccess anillegal
memory location, oratoo-great useofCPU time) .
•Foreach type oferror, theoperating system should take the
appropriate action toensure correct andconsistent computing
•.Debugging facilities can greatly enhance theuser's and
programmer's abilities tousethesystem efficiently
14. OS SERVICES
[Link] allocation .
•When there aremultiple users ormultiple jobs running atthesame
time, resources must beallocated toeach ofthem .
•Many different types ofresources aremanaged bytheoperating
system .Some (such asCPU cycles, main memory, and file
storage) may have special allocation code ,whereas others (such
asI/Odevices) may have much more general request and release
code .
•Forinstance ,indetermining how best tousetheCPU ,operating
systems have CPU -scheduling routines thattake into account the
speed oftheCPU, thejobs thatmust beexecuted, thenumber of
registers available, andother factors .
14. OS SERVICES
[Link] .
Wewant tokeep track ofwhich users usehow much and what kinds of
computer resources .This record keeping may beused foraccounting (sothat
users canbebilled) orsimply foraccumulating usage statistics
[Link] andsecurity .
⮚Protection involves ensuring that allaccess tosystem resources is
controlled .
⮚Security ofthesystem from outsiders isalso important .Such security starts
with requiring each user toauthenticate himself orherself tothesystem,
usually bymeans ofapassword, togain access tosystem resources .
Itextends todefending external I/Odevices, including modems and
network adapters, from invalid access attempts and torecording allsuch
connections fordetection ofbreak -[Link] istobeprotected and
secure, precautions must beinstituted throughout it.
15. USER OPERATING -SYSTEM
INTERFACE
15.1The first approach command -line interface orcommand
interpreter thatallows users todirectly enter commands thatareto
beperformed bytheoperating system .
15.2The second approach allows theuser tointerface with the
operating system viaagraphical user interface orGUI .
109
15.1 Command interpreter
•Themain function ofthecommand interpreter istogetandexecute thenext
user-specified command .
•Many ofthecommands given atthislevel manipulate files:create, delete,
list,print, copy, execute, andsoon.
•TheMS-DOS andUNIX shells operate inthisway.
•There aretwogeneral ways inwhich these commands canbeimplemented .
•Inoneapproach, thecommand interpreter itself contains thecode toexecute
thecommand .Forexample, acommand todelete afilemay cause the
command interpreter tojump toasection ofitscode that sets upthe
parameters andmakes theappropriate system call.
•An alternative approach implements most commands through system
programs .Thus, theUNIX command todelete afile
[Link]
would search forafilecalled rm,load thefileinto memory, andexecute it
with theparameter [Link].110
15. 2 GRAPHICAL USER INTERFACE
•AGUI allows provides amouse -based window -and-menu system asan
interface .
•AGUI provides adesktop metaphor where themouse ismoved to
position itspointer onimages, oricons, onthescreen (thedesktop) that
represent programs, files, directories, andsystem functions .
•Depending onthemouse pointer's location, clicking abutton onthe
mouse caninvoke aprogram, select afileordirectory —known asa
folder —orpulldown amenu thatcontains commands .
•Asavery general rule, many unix users prefer acommand -line
interface asthey often provide powerful shell interfaces .Alternatively,
most windows users arepleased tousethewindows GUI environment
andalmost never usetheMS-DOS shell interface 111
16. SYSTEM CALLS
•The interface between aprocess andanoperating
system isprovided bysystem calls.
•Ingeneral, system calls areavailable asassembly
language instructions .
•They arealso included inthemanuals used bythe
assembly level programmers .
•System calls areusually made when aprocess in
user mode requires access toaresource .Then it
requests thekernel toprovide theresource viaa
system call.
Ascanbeseen from thisdiagram, theprocesses execute normally intheuser mode
until asystem callinterrupts [Link] thesystem callisexecuted onapriority
basis inthekernel mode .After theexecution ofthesystem call, thecontrol returns
totheuser mode andexecution ofuser processes canberesumed .
Ingeneral, system calls arerequired inthefollowing situations −
•Ifafilesystem requires thecreation ordeletion [Link] andwriting from
files alsorequire asystem call.
•Creation andmanagement ofnew processes .
•Network connections also require system [Link] includes sending and
receiving packets .
•Access toahardware devices such asaprinter, scanner [Link] asystem call.
•Let's first use an example to illustrate how system calls are used:
•writing asimple program toread data from onefileandcopy them toanother
file.
•Thefirst input thattheprogram willneed isthenames ofthetwofiles:
•theinput fileandtheoutput [Link] names canbespecified inmany ways,
depending ontheoperating -system design .
•One approach isfortheprogram toasktheuser forthenames ofthetwofiles.
Inaninteractive system ,thisapproach will require asequence ofsystem
calls, first towrite aprompting message onthescreen andthen toread from
thekeyboard thecharacters thatdefine thetwofiles.
•Onmouse -based and icon-based systems, amenu offilenames isusually
displayed inawindow .Theuser canthen usethemouse toselect thesource
name, andawindow canbeopened forthedestination name tobespecified .
This sequence requires many I/Osystem calls.
•Once thetwofilenames areobtained, theprogram must open theinput file
andcreate theoutput [Link] ofthese operations requires another system
call.
•There arealso possible error conditions foreach operation .When the
program tries toopen theinput file, itmay find that there isnofileofthat
name orthatThefileisprotected against access .Inthese cases, theprogram
should print amessage ontheconsole (another sequence ofsystem calls)
andthen terminate abnormally (another system call).
•Iftheinput fileexists ,then wemust create anew output [Link] find
that there isalready anoutput filewith thesame name .This situation may
cause theprogram toabort (asystem call), orwemay delete theexisting
file(another system call) and create anew one (another system call).
Another option, inaninteractive system ,istoasktheuser (viaasequence of
system calls tooutput theprompting message andtoread theresponse from
theterminal) whether toreplace theexisting fileortoabort theprogram .
•Now thatboth files aresetup,weenter aloop thatreads from theinput file(a
system call) andwrites totheoutput file(another system call).Each read andwrite
must return status information regarding various possible error conditions .
•Oninput, theprogram may find thattheendofthefilehasbeen reached orthat
there wasahardware failure intheread (such asaparity error) .
•The write operation may encounter various errors, depending ontheoutput
device (nomore disk space, printer outofpaper, andsoon).
•Finally, after theentire fileiscopied, theprogram may close both files (another
system call), write amessage totheconsole orwindow (more system calls), and
finally terminate normally (thefinal system call).
•Aswecansee, even simple programs may make heavy useoftheoperating
system .Frequently, systems execute thousands ofsystem calls persecond .
17. SYSTEM PROGRAMS
•System programs provide a convenient environment for program development and
execution.
Filemanagement .
•These programs create, delete, copy, rename, print, dump, list,andgenerally manipulate
files anddirectories .
Status information .
•Some programs simply askthesystem forthedate, time, amount ofavailable memory or
disk space, number ofusers, orsimilar status information .
•Detailed performance, logging, and debugging information .Typically, these programs
format andprint theoutput totheterminal orother output devices orfiles ordisplay itin
awindow oftheGUI.
•registry, which isused tostore andretrieve configuration information .
Filemodification .
•Several texteditors may beavailable tocreate andmodify thecontent offiles stored on
disk orother storage devices .
•There may also bespecial commands tosearch contents offiles orperform
transformations ofthetext122
17. SYSTEM PROGRAMS
•Programming -language support .
Compilers, assemblers, debuggers andinterpreters forcommon programming
languages (such asC,C++, java, visual basic, andPERL) areoften provided
totheuser with theoperating system .
•Program loading andexecution
Once aprogram isassembled orcompiled, itmust beloaded intomemory to
beexecuted .The system may provide absolute loaders, relocatable loaders,
linkage editors, and overlay loaders .Debugging systems foreither higher -
level languages ormachine language areneeded aswell.
•Communications
These programs provide themechanism forcreating virtual connections
among processes, users, and computer systems .They allow users tosend
messages tooneanother's screens, tobrowse web pages, tosend electronic -
mail messages, tologinremotely, ortotransfer files from onemachine to
another .123
18. OS DESIGN AND
IMPLEMENTATION
DESIGN GOALS :
•The first problem indesigning asystem istodefine goals and
specifications .Atthehighest level, thedesign ofthesystem willbeaffected
bythechoice ofhardware and thetype ofsystem :batch, time shared,
single user, multiuser, distributed, realtime, orgeneral purpose .
•The requirements can, however, bedivided into two basic groups :user
goals and system goals .Users desire certain obvious properties ina
system :thesystem should beconvenient touse, easy tolearn andtouse,
reliable, safe, andfast.
•Asimilar setofrequirements canbedefined bythose people who must
design, create, maintain, andoperate thesystem :thesystem should beeasy
todesign, implement, and maintain ;itshould beflexible, reliable, error
free, andefficient .
18. OS DESIGN AND
IMPLEMENTATION
•There is,inshort, nounique solution tothe
problem ofdefining the requirements for an
operating system .The wide range ofsystems in
existence shows that different requirements can
result inalarge variety ofsolutions fordifferent
environments .
•Specifying and designing anoperating system is
ahighly creative task
18. OS DESIGN AND
IMPLEMENTATION
MECHANISMS AND POLICIES
•One important principle isthe separation ofpolicy from
mechanism .Mechanisms determine how todosomething ;
policies determine what willbedone .
•For example, thetimer construct isamechanism forensuring CPU
protection, butdeciding how long thetimer istobesetforaparticular user
isapolicy decision .
•Theseparation ofpolicy andmechanism isimportant forflexibility .Policies
arelikely tochange across places orover [Link] case, each
change inpolicy would require achange intheunderlying mechanism .
•For instance, consider amechanism forgiving priority tocertain types of
programs over others .Ifthemechanism isproperly separated from policy, itcan
beused tosupport apolicy decision that I/o-intensive programs should have
priority over cpu-intensive ones ortosupport theopposite policy .
18. OS DESIGN AND
IMPLEMENTATION
•Microkernel -based operating systems take theseparation of
mechanism andpolicy tooneextreme byimplementing a
basic setofprimitive building blocks .These blocks are
almost policy free, allowing more advanced mechanisms
andpolicies tobeadded viauser-created kernel modules or
viauser programs themselves .
•Policy decisions areimportant forallresource allocation .
Whenever itisnecessary todecide whether ornot to
allocate aresource, apolicy decision must bemade .
Whenever thequestion ishow rather than what, itisa
mechanism that must bedetermined
18. OS DESIGN AND
IMPLEMENTATION
IMPLEMENTATION
•Traditionally, operating systems have been written inassembly language .
Now, however, they aremost commonly written inhigher -level languages
such asCorC++.
•The linux and windows XPoperating systems arewritten mostly inC,
although there aresome small sections ofassembly code fordevice drivers
andforsaving andrestoring thestate ofregisters .
18. OS DESIGN AND
IMPLEMENTATION
•IMPLEMENTATION
The advantages ofusing ahigher -level language, oratleast asystems
implementation language, forimplementing operating systems are
•The code canbewritten faster, ismore compact, andiseasier tounderstand
anddebug .
•Inaddition, improvements incompiler technology will improve thegenerated
code fortheentire operating system bysimple recompilation .
•Finally, anoperating system isfareasier toport—tomove tosome other
hardware —
•[Link] example, MS-DOS was written inintel 8088 assembly language .
Consequently, itisavailable ononly theintel family ofCPUs .The linux
operating system, incontrast, iswritten mostly inCand isavailable ona
number ofdifferent CPUs, including intel 80X86,motorola 680X0,SPARC,
andMIPS RXOO 0.
18. OS DESIGN AND
IMPLEMENTATION
IMPLEMENTATION
•The only possible disadvantages ofimplementing anoperating
system inahigher -level language arereduced speed andincreased
storage requirements .
•This, however, isnolonger amajor issue intoday's systems .
Although anexpert assembly -language programmer can produce
efficient small routines, forlarge programs amodern compiler can
perform complex analysis andapply sophisticated optimizations that
produce excellent code .
•Modern processors have deep pipelining and multiple functional
units thatcanhandle complex dependencies thatcanoverwhelm the
limited ability ofthehuman mind tokeep track ofdetails .
19. OS STRUCTURES
Operating system canbeimplemented with thehelp
ofvarious structures .The structure ofthe OS
depends mainly onhow the various common
components of the operating system are
interconnected andmelded intothekernel .
[Link]
[Link]
[Link]
[Link]
19.1 SIMPLE STRUCTURE
•Operating systems donot have well defined
structure andaresmall, simple andlimited systems .
•The interfaces and levels offunctionality arenot
well separated .
•MS-DOS isanexample ofsuch operating system .
InMS-DOS application programs are able to
access thebasic I/Oroutines .
•These types ofoperating system cause theentire
system tocrash ifoneoftheuser programs fails.
19.1 SIMPLE STRUCTURE
19.1 SIMPLE STRUCTURE
ADVANTAGES OF SIMPLE STRUCTURE:
•Itdelivers better application performance because ofthefew
interfaces between the application program and the
hardware .
•Easy forkernel developers todevelop such anoperating
system .
DISADVANTAGES OF SIMPLE STRUCTURE:
•The structure isvery complicated asnoclear boundaries
exists between modules .
•Itdoes notenforce data hiding intheoperating system .
19.2 LAYERED STRUCTURE
•AnOScanbebroken intopieces andretain much more control
onsystem .
•Inthis structure theOSisbroken into number oflayers
(levels) .
•The bottom layer (layer 0)isthehardware andthetopmost
layer (layer N)istheuser interface .
•These layers aresodesigned thateach layer uses thefunctions
ofthelower level layers only.
19.2 LAYERED STRUCTURE
19.2 LAYERED STRUCTURE
Advantages of layered structure:
•Layering makes it easier to enhance the operating system
as implementation of a layer can be changed easily
without affecting the other layers.
•It is very easy to perform debugging and system
verification.
Disadvantages of layered structure:
•It requires careful planning for designing the layers as
higher layers use the functionalities of only the lower
layers.
19.3 MICROKERNEL
•Microkernel isone oftheclassification ofthekernel .Being akernel it
manages all system resources .But inamicrokernel, the user
services andkernel services areimplemented indifferent address space .The
user services arekept inuser address space ,andkernel services arekept
under kernel address space ,thus also reduces thesize ofkernel andsize of
operating system aswell.
•Since kernel isthecore part oftheoperating system, soitismeant forhandling the
most important services only.
•Thus inthisarchitecture only themost important services areinside kernel andrestof
theOSservices arepresent inside system application program .Thus users areable to
interact with those not-soimportant services within thesystem application .And the
microkernel issolely responsible forthemost important services ofoperating
system they arenamed asfollows :
•Inter process -communication
•Memory management
•CPU -scheduling
139
19.3 MICROKERNEL
Advantages of micro -kernel structure:
•It makes the operating system portable to various
platforms.
•As microkernels are small so these can be tested
effectively.
Disadvantages of micro -kernel structure:
•Increased level of inter module communication degrades
system performance.
19.4 MODULAR STRUCTURE
•It is considered as the best approach for an OS.
•It involves designing of a modular kernel.
•The kernel has only set of core components and other services
are added as dynamically loadable modules to the kernel either
during run time or boot time.
•It resembles layered structure due to the fact that each kernel
has defined and protected interfaces but it is more flexible than
the layered structure as a module can call any other module.
19.4 MODULAR STRUCTURE
•FOR EXAMPLE SOLARIS OS IS ORGANIZED AS SHOWN IN THE
FIGURE.
19.4 MODULAR STRUCTURE
•Theprimary benefit ofthemodular approach isthateach process
operates independently ,and ifone ofthem fails orneeds an
update, itwon't affect anyoftheother functions .
•Easy todebug andupdate
Limitations:
•It may lose stability. If there is a module that does something
bad, the kernel can crash, as modules should have full
permissions and therefore security is compromised
20. VIRTUALIZATION
•Virtualization isaprocess that allows formore efficient utilization ofphysical
computer hardware andisthefoundation ofcloud computing .
•Virtualization uses software tocreate anabstraction layer over computer hardware
that allows thehardware elements ofasingle computer —processors, memory,
storage and more —tobedivided into multiple virtual computers, commonly
called virtual machines (vms) .
•Each vmruns itsown operating system (os) andbehaves likeanindependent
computer, even though itisrunning onjustaportion oftheactual underlying
computer hardware .
•Itfollows that virtualization enables more efficient utilization ofphysical
computer hardware and allows agreater return onanorganization’s hardware
investment .
BENEFITS OF VIRTUALIZATION
[Link] EFFICIENCY :
Before virtualization, each application server required itsown
dedicated physical CPU —ITstaff would purchase and configure a
separate server foreach application they wanted torun.(ITpreferred
one application and one operating system (OS) percomputer for
reliability reasons .)Invariably, each physical server would be
underused .
Incontrast, server virtualization letsyou runseveral applications —
each onitsown VM with itsown os—onasingle physical computer
(typically anx86server) without sacrificing reliability .This enables
maximum utilization ofthephysical hardware’s computing capacity .
BENEFITS OF VIRTUALIZATION
2. EASIER MANAGEMENT:
Replacing physical computers with software -defined VMs makes it
easier touseandmanage policies written insoftware .This allows
youtocreate automated ITservice management workflows .
Forexample, automated deployment andconfiguration tools enable
administrators todefine collections ofvirtual machines and
applications asservices, insoftware templates .
This means that they can install those services repeatedly and
consistently without cumbersome, time-consuming anderror -prone
manual setup .
Admins canusevirtualization security policies tomandate certain
security configurations based ontherole ofthevirtual machine .
Policies caneven increase resource efficiency byretiring unused
virtual machines tosave onspace andcomputing power .
BENEFITS OF VIRTUALIZATION
3. Faster provisioning:
Buying, installing, and configuring hardware for each application istime-
consuming .
Provided thatthehardware isalready inplace, provisioning virtual machines torun
allyour applications issignificantly faster .
You caneven automate itusing management software andbuild itinto existing
workflows .
OS LEVEL VIRTUALIZATION
•The fundamental idea behind avirtual machine istoabstract thehardware
ofasingle computer (the CPU, memory, disk drives, network interface
cards, and soforth) into several different execution environments, thereby
creating theillusion that each separate execution environment isrunning
itsown private computer .
•Itisalso called OS-level virtualization isatype ofvirtualization technology
which work onOSlayer .Here thekernel ofanOSallows more than one
isolated user-space instances to exist .Such instances are called
containers/software containers orvirtualization engines .
•Inother words, OSkernel will runasingle operating system &provide that
operating system's functionality toreplicate oneach ofthe isolated
partitions .
IMPLEMENTATION
•Although thevirtual -machine concept isuseful, itisdifficult toimplement .
Much work isrequired toprovide anexact duplicate oftheunderlying machine .
Remember that theunderlying machine has two modes :user mode and
kernel mode .
•Thevirtual -machine software canruninkernel mode, since itistheoperating
system .The virtual machine itself canexecute inonly user mode .Just asthe
physical machine hastwomodes, however, somust thevirtual machine .
•Consequently, wemust have avirtual user mode andavirtual kernel mode, both
ofwhich runinaphysical user mode .Those actions thatcause atransfer from
user mode tokernel mode onarealmachine (such asasystem calloranattempt
toexecute aprivileged instruction) must also cause atransfer from virtual user
mode tovirtual kernel mode onavirtual machine .
BENEFITS
•There isnodirect sharing ofresources .Two approaches
toprovide sharing have been implemented .
•First, itispossible toshare aminidisk andthus toshare
[Link] scheme ismodeled after aphysical shared
disk butisimplemented bysoftware .
•Second, itispossible todefine anetwork ofvirtual
machines, each ofwhich cansend information over the
virtual communications network .Again, thenetwork is
modeled after physical communication networks butis
implemented insoftware .
VMWARE VIRTUAL MACHINE
•Vmware isapopular commercial application thatabstracts intel 80X86hardware
intoisolated virtual machines .
•Vmware runs asanapplication onahost operating system such aswindows orlinux
andallows thishost system toconcurrently runseveral different guest operating
systems asindependent virtual machines .
Consider thefollowing scenario :adeveloper hasdesigned anapplication andwould
liketotestitonlinux, freeBSD, windows NT, andwindows XP.
•One option istoobtain four different computers, each running acopy ofoneof
these operating systems .
•Another alternative isforherfirst toinstall linux onacomputer system andtestthe
application, then toinstall freeBSD and testtheapplication, and soforth .This
option allow tousethesame physical computer butistime-consuming, since
installation ofanew operating system foreach testisrequired .
VMWARE VIRTUAL MACHINE
Solution :Such testing could beaccomplished concurrently onthesame
physical computer using VMware .Inthiscase, theprogrammer could test
theapplication onahost operating system andonthree guest operating
systems with each system running asaseparate virtual machine .
VMWARE VIRTUAL MACHINE
•Inthis scenario, linux isrunning asthe host operating
system ;freebsd, windows NT, and windows XP are
running asguest operating systems .
•The virtualization layer isthe heart ofvmware, asit
abstracts thephysical hardware into isolated virtual machines
running asguest operating systems .
•Each virtual machine hasitsown virtual CPU, memory, disk
drives, network interfaces, andsoforth