Operating System Lec 2
-
Upload
abdul-basit -
Category
Documents
-
view
220 -
download
0
Transcript of Operating System Lec 2
-
8/18/2019 Operating System Lec 2
1/38
OPERATING SYSTEM LEC
2
-
8/18/2019 Operating System Lec 2
2/38
System Call
Provides the interfae !et"een a #roess and the OS
It is an instr$tion that %enerates an interr$#t that a$ses OS to %ain ontrol
of #roessor&
Proess re'$est ation !y OS&
-
8/18/2019 Operating System Lec 2
3/38
System Calls
Interfae !et"een r$nnin%
#ro%ram and the OS&
◦ Assem!ly lan%$a%e instr$tions
(maros and s$!ro$tines)
◦ Some hi%her level lan%$a%es
allo" system alls to !e made
diretly (e&%& C)
Passin% #arameters !et"een a
r$nnin% #ro%ram and OS via
re%isters* memory ta!les or
sta+&
,ni- has a!o$t .2 system alls
◦ read()* "rite()* o#en()* lose()*
for+()* e-e()* iotl()*/&&
-
8/18/2019 Operating System Lec 2
4/38
Ty#es of System Calls
Proess ontrol0 end1a!ort* load1e-e$te* reate1terminate* "ait for event ile mana%ement0 reate* delete* o#en lose* %et file attri!$tes 3evie mana%ement0 re'$est* release* read* "rite* %et1set devie
attri!$tes* attah* detah& Info maintenane0 time* date Comm$niation0o#en onnetion* lose onnetion
-
8/18/2019 Operating System Lec 2
5/38
Ma4or om#onents
Proess mana%ement Memory mana%ement I1O Seondary Stora%e ile System Protetion Ao$ntin%
Shell (OS ,I) G,I Net"or+in%
-
8/18/2019 Operating System Lec 2
6/38
Proess Mana%ement
A #roess is a #ro%ram in e-e$tion&
A #roess needs ertain reso$res s$h as CP,* memory *
files and I1O&
These reso$res are %iven "hen a #roess is reated
5hen the #roess terminates* OS relaims the reso$res
Pro%ram0 #assive
Proess0ative
At most one instr$tion is e-e$ted on !ehalf of a #roess
-
8/18/2019 Operating System Lec 2
7/38
Proesses
Scheduler 6 Maintains a reord
of the #roesses&
Adds ne" #roesses "hen
la$nhed&
Removes old #roesses "hen
om#leted&
,ses a #roess ta!le& Process Table 6 Information
a!o$t eah #roess inl$din%7
Main memory ells (RAM)
Priority
R$nnin% or "aitin% (in#$t
from $ser or savin% to dis+) Ri+ Gra8iani%ra8iani9a!rillo&ed$
7
-
8/18/2019 Operating System Lec 2
8/38
:ie"in% #roesses "ith Mirosoft 5indo"s
Tas+ ;ar 6 Ri%ht0li+* Tas+ Mana%er
Endin% a #roess 6 Killing the process Ri+ Gra8iani%ra8iani9a!rillo&ed$
8
-
8/18/2019 Operating System Lec 2
9/38
Proesses Dispatcher 0 Oversees the
e-e$tion of eah #roess !y theCP,&
Gives eah #roess a time slie of
CP, time&
Chan%es !et"een #roesses&
Ri+ Gra8iani%ra8iani9a!rillo&ed$
9
-
8/18/2019 Operating System Lec 2
10/38
Proess mana%ement
The OS is res#onsi!le for◦ Create $ser1 system #roesses
◦ 3eletin% $ser1system #roesses
◦ Alloatin% hard"are reso$res to a #roess&
◦ Proess omm$niation
◦ 3eadlo+ handlin%
◦
S$s#end a #roess◦ Res$me a #roess
◦ Clone a #roess
◦ Inter0#roess omm$niation
◦ Inter0#roess synhroni8ation
◦ Create 1 delete a hild #roess
-
8/18/2019 Operating System Lec 2
11/38
Memory Mana%ement
Conerned "ith the mana%ement of #rimary memory
5hih #art s !ein% $sed
5hih #roesses are to !e loaded
Alloation tehni'$es
3e0alloation tehni'$es
-
8/18/2019 Operating System Lec 2
12/38
ile Mana%ement
A file is a lo%ial olletion of information
OS #rovides a lo%ial vie"
OS reate* deletes files
OS ma#s files onto seondary stora%e
Creatin%1deletin% diretories&
;a+in% $# files
-
8/18/2019 Operating System Lec 2
13/38
Seondary stora%e Mana%ement
OS is res#onsi!le for 7
free s#ae mana%ement
Stora%e alloation
3is+ shed$lin%
-
8/18/2019 Operating System Lec 2
14/38
I1O Mana%ement
I1O ontroller +ee#s tra+ of the stat$s of the devies ;$fferin%* ahin%* s#oolin% 3evie driver interfae 3rivers0 3evie drivers are the ro$tines that interat "ith s#eifi
devie ty#es7
Ena#s$lates devie s#eifi +no"led%e
E&%& ho" to initiali8e a devie* ho" to re'$est the I1O*
ho" to handle interr$#ts and errors
E&%& SCSI devie drivers* Ethernet ard drivers*
video ard drivers* so$nd ard drivers
-
8/18/2019 Operating System Lec 2
15/38
I1O Str$t$re
Synhrono$s I1O
wait instr$tion idles CP, $ntil ne-t interr$#t
no sim$ltaneo$s I1O #roessin%* at most one o$tstandin%
I1O re'$est at a time&
Asynhrono$s I1O
After I1O is initiated* ontrol ret$rns to $ser #ro%ram
"itho$t "aitin% for I1O om#letion&
-
8/18/2019 Operating System Lec 2
16/38
Net"or+in%
An OS ty#ially has a !$ilt0in omm$niation infra0str$t$re that
im#lements7 A net"or+ #rotool soft"are sta+
A ro$te loo+$# mod$le to ma# a %iven destinationaddress to a ne-t ho#&
A name loo+$# servie to ma# a %iven name to adestination mahine&
-
8/18/2019 Operating System Lec 2
17/38
A particular program that handles thinterpretation of users• commands and helps to manage processes
On some systems, command interpreter may• be a standard part of the OS
On others, its just not privileged code that• provides an interface to the user
On others there may be no command language
Command inter#reter (she
-
8/18/2019 Operating System Lec 2
18/38
•Keeps track of resource usage
•Both to enforce quotas “youreover the disk limit!"
Accounting
-
8/18/2019 Operating System Lec 2
19/38
Protetion
Proessor #rotetion
Protetion mehanisms are im#lement in OS to s$##ort se$rity #oliies&
The %oal of se$rity system is to a$thentiate and a$thori8e&
-
8/18/2019 Operating System Lec 2
20/38
-
8/18/2019 Operating System Lec 2
21/38
3$al Mode
Gives #rotetion or shared reso$res ,ser mode* #rivile%ed mode A mode !it is added to the hard"are to indiate the mode 5ith the mode !it it is #ossi!le to distin%$ish !et"een the modes& On !ootin% $ser #roess starts in $ser mode& If an attem#t is made to e-e$te a #rivile%ed instr$tion in $ser mode the
hard"are tra#s it to the OS&
-
8/18/2019 Operating System Lec 2
22/38
3$al0mode o#eration(ont&)
Mode !it added to om#$terhard"are to indiate the
$rrent mode7 monitor(=) or$ser(>)&
5hen an interr$#t or fa$lto$rs* hard"are s"ithes tomonitor mode&
Privile%ed instr$tions only in
monitor mode&
User
Monitor
Set
user
mod
Interrupt/
fault
-
8/18/2019 Operating System Lec 2
23/38
3$al0mode o#eration
Sharin% system reso$res re'$ires o#eratin% syste
to ens$re that an inorret #ro%ram annot a$seother #ro%rams to e-e$te inorretly&
Provide hard"are s$##ort to differentiate !et"ee
at least t"o modes of o#eration7
>& ,ser mode 00 e-e$tion done on !ehalf of a $ser&
2& Monitor mode (s$#ervisor1+ernel1system mode) 00
e-e$tion done on !ehalf of o#eratin% system&
-
8/18/2019 Operating System Lec 2
24/38
I1O Protetion
All I1O instr$tions are #rivile%ed instr$tions&
M$st ens$re that a $ser #ro%ram o$ld never %ain
ontrol of the om#$ter in monitor mode* for e&%& a
$ser #ro%ram that as #art of its e-e$tion* stores ane" address in the interr$#t vetor&
-
8/18/2019 Operating System Lec 2
25/38
Memory Protetion
M$st #rovide memory #rotetion
at least for the interr$#t vetorand the interr$#t serviero$tines&
To #rovide memory #rotetion*add t"o re%isters that determinethe ran%e of le%al addresses a#ro%ram may address&◦ ;ase Re%ister 0 holds smallest
le%al #hysial memory address&◦ Limit re%ister 0 ontains the si8e
of the ran%e&
Memory o$tside the definedran%e is #roteted&
5hen e-e$tin% in monitor mode*the OS has $nrestrited aess to!oth monitor and $sers? memory&
0
256000
3000040
420940
880000
1024000
300
120
Base r
imit re
monitor
!o"1
!o" 2
!o" 4
!o" 3
0
-
8/18/2019 Operating System Lec 2
26/38
CP, Protetion
Timer 0 interr$#ts om#$ter after s#eified #eriod to
ens$re that OS maintains ontrol&
Timer is deremented every lo+ ti+&
5hen timer reahes a val$e of =* an interr$#t o$rs&
Timer is ommonly $sed to im#lement time sharin%& Timer is also $sed to om#$te the $rrent time&
Load timer is a #rivile%ed instr$tion&
-
8/18/2019 Operating System Lec 2
27/38
O#eratin% Systems7
-
8/18/2019 Operating System Lec 2
28/38
OS structure #ts not al$ays clear ho$ to stitch OS modules
together%
MemoryManagement
I/O System
Secondary StorageManagement
File System
Protection System
Accounting System
Process Management
Command Interpreter
Information Services
Error Handling
-
8/18/2019 Operating System Lec 2
29/38
Early structure: Monolithic &raditionally, OSs 'like ()#*, +OS $ere built as a
monolithic entity%
everything
user programs
hard$are
OS
-
8/18/2019 Operating System Lec 2
30/38
Monolithi 3esi%n
Ma4or Advanta%es7
Cost of mod$le interation is lo"
3isadvanta%es
-
8/18/2019 Operating System Lec 2
31/38
Monolithi 3esi%n
Ma4or Advanta%es7 Cost of mod$le interation is lo"
3isadvanta%es
-
8/18/2019 Operating System Lec 2
32/38
3esi%n
To# do"n a##roah 6 overall f$ntionality is se#arated into om#onents&
Layered a##roah 6 eah layer $ses servies of lo"er layers& Needs aref$l
definition of eah layer& Layer N is $ser* Layer = is hard"are&
La ered OS Str t re
-
8/18/2019 Operating System Lec 2
33/38
Layered OS Str$t$re
OS divided into n$m!er of
layers 0 !ottom layer ishard"are* hi%hest layer is
the $ser interfae&
Eah layer $ses f$ntions
and servies of only lo"er0
level layers&
T
-
8/18/2019 Operating System Lec 2
34/38
Layered O#eratin% System
-
8/18/2019 Operating System Lec 2
35/38
Mod$les0!ased Str$t$re
Most modern o#eratin% systems im#lement mod$les
,ses o!4et0oriented a##roah
Eah ore om#onent is se#arate
Eah tal+s to the others over +no"n interfaes
Eah is loada!le as needed "ithin the +ernel
Overall* similar to layers !$t "ith more fle-i!le
O-./A)0 S1S&.2h i
-
8/18/2019 Operating System Lec 2
36/38
36
O-./A)0 S1S&.2O3./3#.4
5haracterist
#nterrupts%• #nterrupt transfers control to the interrupt service routine genera
through the interrupt vector , $hich contains the addresses ofthe service routines"
• #nterrupt architecture must save the address of the interrupinstruction"
• #ncoming interrupts are disabled $hile another interrupt is beprocessed to prevent a lost interrupt "
• A trap is a soft$are6generated interrupt caused either by an eor a user request"
• An operating system is interrupt driven"
O-./A)0 S1S&.2 St
-
8/18/2019 Operating System Lec 2
37/38
:ery fast stora%e is very e-#ensive& So the O#eratin% System mana%es a hierarhy ofstora%e devies in order to ma+e the !est $se of reso$res& In fat* considerable effo%oes into this s$##ort&
37
O-./A)0 S1S&.2O3./3#.4
Storage7ierarchy
8ast and .9pensive
Slo$ an 5heap
:irt$al Mahines
-
8/18/2019 Operating System Lec 2
38/38
:irt$al Mahines
Lo%ially treats hard"ar
and OS +ernel ashard"are
Provides interfaeidential to $nderlyin%!are hard"are&
Creates ill$sion ofm$lti#le #roesses 0 ea"ith its o"n #roessorand virt$al memory
#ard$are
%irtual maine
'ernel 'ernel 'ernel
pro&esses
pro&esses
pro&esses