7/25/2019 OS3 - Principles Of
1/39
Principles of
Operating Systems
Operating System Structures
Saiful Anwar
State Polytechnic of Jakarta
January, 2007
7/25/2019 OS3 - Principles Of
2/39
Computer System Structures
Computer System Operation
IO Structure
Storage Structure
Storage !ierarchy
!ar"ware Protection
#eneral System Architecture
7/25/2019 OS3 - Principles Of
3/39
Computer System Architecture
7/25/2019 OS3 - Principles Of
4/39
Computer System Organi$ation
IO "e%ices an" the CP& e'ecute concurrently(
)ach "e%ice controller is in charge of a particular
"e%ice type
)ach "e%ice controller has a local *uffer( IO is from the"e%ice to local *uffer of controller
CP& mo%es "ata fromto main memory tofrom
the local *uffers
+e%ice controller interrupts CP& on completion
of IO
7/25/2019 OS3 - Principles Of
5/39
Interrupts
Interrupt transfers control to the interrupt ser%ice
routineInterrupt Ser%ice outine- Segments of co"e that
"etermine action to *e taken for each type of interrupt(
Interrupt %ector contains the a""ress of ser%ice routines(
OS preser%es the state of the CP&stores registers an" the program counter .a""ress of
interrupte" instruction/(
Trapsoftware generate" interrupt cause" either *y an error
or a user reuest(
7/25/2019 OS3 - Principles Of
6/39
Interrupt !an"ling
1ypes of interruptPolling
ectore" interrupt system
Incoming interrupts are "isa*le" while another
interrupt is *eing processe" to pre%ent a lost
interrupt(
7/25/2019 OS3 - Principles Of
7/39
IO Structure
Synchronous IOwaitinstruction i"les CP& until ne't interrupt
no simultaneous IO processing, at most one outstan"ing
IO reuest at a time(
Asynchronous IOAfter IO is initiate", control returns to user program without
waiting for IO completion(
System call
+e%ice Status ta*le 3 hol"s type, a""ress an" state foreach "e%ice
OS in"e'es into IO "e%ice ta*le to "etermine "e%ice status
an" mo"ify ta*le entry to inclu"e interrupt(
7/25/2019 OS3 - Principles Of
8/39
+irect 4emory Access .+4A/
&se" for high spee" IO
"e%ices a*le to transmit
information at close to
memory spee"s(
+e%ice controller transfers*locks of "ata from *uffer
storage "irectly to main
memory without CP&
inter%ention(
Only one interrupt is
generate" per *lock, rather
than one per *yte .or wor"/(
MemoryMemory
CPUCPU I/O devicesI/O devicesI/O instructions
7/25/2019 OS3 - Principles Of
9/39
Storage Structure
4ain memory 3 only large storage me"ia that the
CP& can access "irectly(
Secon"ary storage 3 e'tension of main memory
that has large non%olatile storage capacity(4agnetic "isks 3 rigi" metal or glass platters co%ere"
with magnetic recor"ing material(
+isk surface is logically "i%i"e" into tracks,
su*"i%i"e" into sectors(+isk controller "etermines logical interaction
*etween "e%ice an" computer(
7/25/2019 OS3 - Principles Of
10/39
Storage !ierarchy
Storage systems are organi$e" in a hierarchy
*ase" onSpee"
Costolatility
Caching 3 process of copying information into
faster storage system5 main memory can *e
%iewe" as fast cache for secon"ary storage(
7/25/2019 OS3 - Principles Of
11/39
Storage +e%ice !ierarchy
7/25/2019 OS3 - Principles Of
12/39
!ar"ware Protection
+ual 4o"e Operation
IO Protection
4emory Protection
CP& Protection
7/25/2019 OS3 - Principles Of
13/39
+ual3mo"e operation
Sharing system resources reuires operating
system to ensure that an incorrect program
cannot cause other programs to e'ecute
incorrectly(
Pro%i"e har"ware support to "ifferentiate
*etween at least two mo"es of operation-
6( &ser mo"e 33 e'ecution "one on *ehalf of a user(
2( 4onitor mo"e .super%isorkernelsystem mo"e/ 33
e'ecution "one on *ehalf of operating system(
7/25/2019 OS3 - Principles Of
14/39
+ual3mo"e operation.cont(/
4o"e *it a""e" tocomputer har"ware toin"icate the currentmo"e- monitor.0/ oruser.6/(
hen an interrupt orfault occurs, har"wareswitches to monitormo"e(
Pri%ilege" instructionsonly in monitor mo"e(
User
Monitor
Set
user
mode
Interrupt/
fault
7/25/2019 OS3 - Principles Of
15/39
IO Protection
All IO instructions are pri%ilege"
instructions(
4ust ensure that a user program coul"
ne%er gain control of the computer in
monitor mo"e, for e(g( a user program that
as part of its e'ecution, stores a new
a""ress in the interrupt %ector(
7/25/2019 OS3 - Principles Of
16/39
4emory Protection
4ust pro%i"e memoryprotection at least for theinterrupt %ector an" theinterrupt ser%ice routines(
1o pro%i"e memoryprotection, a"" two registersthat "etermine the range oflegal a""resses a programmay a""ress( 8ase egister 3 hol"s smallest
legal physical memory a""ress( 9imit register 3 contains the si$e
of the range(
4emory outsi"e the "efine"range is protecte"(
0
256000
300000
20!0
""0000
#02000
30000
#20!00
$ase re%ister
&imit re%ister
monitor
'o(#
'o( 2
'o(
'o( 3
0
7/25/2019 OS3 - Principles Of
17/39
!ar"ware A""ress Protection
7/25/2019 OS3 - Principles Of
18/39
Protection !ar"ware .cont(/
hen e'ecuting in monitor mo"e, the OS has
unrestricte" access to *oth monitor an" users:
memory(
1he loa" instructions for the basean" limit
registers are pri%ilege" instructions(
7/25/2019 OS3 - Principles Of
19/39
CP& Protection
1imer 3 interrupts computer after specifie"
perio" to ensure that OS maintains control(1imer is "ecremente" e%ery clock tick(
hen timer reaches a %alue of 0, an interrupt occurs(1imer is commonly use" to implement time
sharing(
1imer is also use" to compute the current time(
9oa" timer is a pri%ilege" instruction(
7/25/2019 OS3 - Principles Of
20/39
#eneral System Architecture
#i%en the IO instructions are pri%ilege", how "o
users perform IO;
ia system calls 3 the metho" use" *y a processto reuest action *y the operating system(
7/25/2019 OS3 - Principles Of
21/39
Operating System Structures
Operating System ComponentsProcess 4anagement, 4emory 4anagement,
Secon"ary Storage 4anagement, IO System
4anagement,
7/25/2019 OS3 - Principles Of
22/39
Process 4anagement .Chapters >37/
Process 3 fun"amental concept in OSProcess is a program in e'ecution(
Process nee"s resources 3 CP& time, memory, files"ata
an" IO "e%ices(
OS is responsi*le for the following process
management acti%ities(Process creation an" "eletion
Process suspension an" resumptionProcess synchroni$ation an" interprocess communication
Process interactions 3 "ea"lock "etection, a%oi"ance an"
correction
7/25/2019 OS3 - Principles Of
23/39
4emory 4anagement .Chapters ?3@/
4ain 4emory is an array of a""ressa*le wor"s or
*ytes that is uickly accessi*le(
4ain 4emory is %olatile(
OS is responsi*le for-Allocate an" "eallocate memory to processes(
4anaging multiple processes within memory 3 keep
track of which parts of memory are use" *y which
processes( 4anage the sharing of memory *etweenprocesses(
+etermining which processes to loa" when memory
*ecomes a%aila*le(
7/25/2019 OS3 - Principles Of
24/39
Secon"ary Storage an" IO
4anagement .Chapter 60/
Since primary storage is e'pensi%e an" %olatile,
secon"ary storage is reuire" for *ackup(
+isk is the primary form of secon"ary storage(
OS performs storage allocation, free3spacemanagement an" "isk sche"uling(
IO system in the OS consists of8uffer caching an" management
+e%ice "ri%er interface that a*stracts "e%ice "etails
+ri%ers for specific har"ware "e%ices
7/25/2019 OS3 - Principles Of
25/39
7/25/2019 OS3 - Principles Of
26/39
Protection an" Security .Chapter 6>/
Protection mechanisms control access of programs
an" processes to user an" system resources(
Protect user from himself, user from other users, system
from users(
Protection mechanisms must-
+istinguish *etween authori$e" an" unauthori$e" use(
Specify access controls to *e impose" on use(
Pro%i"e mechanisms for enforcement of access control(
Security mechanisms pro%i"e trust in system an"
pri%acy
authentication, certification, encryption etc(
7/25/2019 OS3 - Principles Of
27/39
=etworking .+istri*ute" Systems/
+istri*ute" System is a collection of processors
that "o not share memory or a clock(
Processors are connecte" %ia a communication
network(A"%antages-Allows users an" system to e'change information
pro%i"e computational spee"up
increase" relia*ility an" a%aila*ility of information
7/25/2019 OS3 - Principles Of
28/39
Comman" Interpreter System
Comman"s that are gi%en to the operating
system %ia comman" statements that e'ecuteProcess creation an" "eletion, IO han"ling, Secon"ary
Storage 4anagement, 4ain 4emory 4anagement,
7/25/2019 OS3 - Principles Of
29/39
Operating System Ser%ices
Ser%ices that pro%i"e user3interfaces to OSProgram e'ecution 3 loa" program into memory an" run it
IO Operations 3 since users cannot e'ecute IO operations
"irectly
7/25/2019 OS3 - Principles Of
30/39
System Calls
Interface *etween running program an" the OS(Assem*ly language instructions .macros an"
su*routines/
Some higher le%el languages allow system calls to *ema"e "irectly .e(g( C/
Passing parameters *etween a running program
an" OS %ia registers, memory ta*les or stack(
&ni' has a*out 2 system callsrea"./, write./, open./, close./, fork./, e'ec./, ioctl./,D((
7/25/2019 OS3 - Principles Of
31/39
System Programs
Con%enient en%ironment for program "e%elopment an"
e'ecution( &ser %iew of OS is "efine" *y system
programs, not system calls(
Comman" Interpreter .sh, csh, ksh/ 3 parsese'ecutes othersystem programs
7/25/2019 OS3 - Principles Of
32/39
System +esign an" Implementation
)sta*lish "esign goals&ser #oals
System #oals
Software )ngineering 3Separate mechanism from policy( Policies "etermine
what nee"s to *e "one, mechanisms "etermine how
they are "one(
Choose a high3le%el implementation languagefaster implementation, more compact, easier to "e*ug
7/25/2019 OS3 - Principles Of
33/39
System #eneration
OS written for a class of machines, must *e
configure" for each specific site(SES#)= program o*tains info a*out specific har"ware
configuration an" creates %ersion of OS for har"ware8ooting
8ootstrap program 3 loa"er program loa"s
kernel, kernel loa"s rest of OS(
8ootstrap program store" in O4
7/25/2019 OS3 - Principles Of
34/39
OS Structure 3 Simple Approach
4S3+OS 3 pro%i"es a lot of functionality in little
space(=ot "i%i"e" into mo"ules, Interfaces an" le%els of
functionality are not well separate"&=I 3 limite" structuring, has 2 separa*le partsSystems programs
Fernel
e%erything *elow system call interface an" a*o%ephysical har"ware(
7/25/2019 OS3 - Principles Of
35/39
&=I System Structure
7/25/2019 OS3 - Principles Of
36/39
9ayere" OS Structure
OS "i%i"e" into num*er of
layers 3 *ottom layer is
har"ware, highest layer is
the user interface(
)ach layer uses functions
an" ser%ices of only lower3
le%el layers(
1!) Operating System
Fernel has successi%e
layers of a*straction(
7/25/2019 OS3 - Principles Of
37/39
irtual 4achines
9ogically treats har"warean" OS kernel ashar"ware
Pro%i"es interfacei"entical to un"erlying*are har"ware(
Creates illusion ofmultiple processes 3 eachwith its own processoran" %irtual memory
)ard*are
+irtual mac)ine
,ernel ,ernel ,ernel
processes
processes
processes
7/25/2019 OS3 - Principles Of
38/39
Summary of OS Structures
Operating System Concepts
Operating System Ser%ices, System Programs
an" System calls
Operating System +esign an" Implementation
Structuring Operating Systems
7/25/2019 OS3 - Principles Of
39/39
1he en" of this presentation
1hank you for yours attentionD