Comput er Syst em Overview I nt roduct ion A comput er syst em - - PowerPoint PPT Presentation
Comput er Syst em Overview I nt roduct ion A comput er syst em - - PowerPoint PPT Presentation
Comput er Syst em Overview I nt roduct ion A comput er syst em consist s of har dwar e syst em pr ogr ams applicat ion pr ogr ams 2 Oper at ing Syst em Pr ovides a set of ser vices t o syst em user s (collect ion of
2
I nt roduct ion
- A comput er syst em consist s of
– har dwar e – syst em pr ogr ams – applicat ion pr ogr ams
3
Oper at ing Syst em
- Pr ovides a set of ser vices t o syst em user s (collect ion
- f ser vice pr ogr ams)
- Shield bet ween t he user and t he har dwar e
- Resour ce manager :
– CPU(s) – memor y and I / O devices
4
Comput er syst em over view: st ar t ing f r om 0 Basic f unct ionalit y of a comput er syst em: I nst r uct ion Cycle
5
A closer -t o-r ealit y-view of t odays’ pr ocessor s (a) A t hr ee-st age pipeline (b) A super scalar CPU (c – to appear) Multicore CPUs
6
Basic Element s of a Comput er Syst em
- Pr ocessor + r egist er s
- Main Memor y (“r eal” or
pr imar y memor y) – volat ile
- I / O modules
– secondar y memor y devices – communicat ions equipment – t er minals
- Syst em bus
– communicat ion among pr ocessor s, memor y, and I / O modules
7
Regist er s: 1. User -Visible
- May be r ef er enced by machine lang.
– By bot h applicat ion and syst em programs
- Enable pr ogr ammer t o minimize main-
memor y r ef er ences by opt imizing r egist er use
- Types of user -visible r egist er s
– Dat a – Addr ess
- I ndex: f or indexed addressing,
- f f set
- St ack point er: f or procedure calling
8
Regist er s: 2. Cont r ol and St at us
- Used by
– pr ocessor t o cont r ol execut ion – oper at ing-syst em t o cont r ol t he execut ion of pr ogr ams
- Basic C&S r egist er s:
– Program Count er (PC)
- Cont ains t he address of an
inst ruct ion t o be f et ched – I nst ruct ion Regist er (I R)
- Cont ains t he inst ruct ion most
recent ly f et ched – Program St at us Word (PSW)
- condit ion codes (posit ive/ negat ive/
zero result , overf low, … )
- I nt errupt enable/ disable
- Supervisor/ user mode
9
I nst r uct ion Cycle r evisit
- Pr ocessor f et ches inst r uct ion f r om memor y
– Program count er (PC) holds address of inst ruct ion t o be f et ched next ; PC is increment ed af t er each f et ch – Fet ched inst ruct ion is placed in t he inst ruct ion regist er
- Types of inst r uct ions
– Pr ocessor -memor y – Pr ocessor -I / O – Dat a pr ocessing – Cont r ol: alt er sequence of execut ion
10
I s t hat enough f or ....
- Component s of a simple personal comput er
Monitor
Bus
11
I nt errupt s!
- An int errupt ion of t he normal sequence of
execut ion! Why?
– Somet hing went wr ong (div. by 0, r ef er ence
- ut side user ’s memor y space, har dwar e f ailur e,…
) – Timer – I / O
- and t hen?
– I nt er r upt handler t akes cont r ol:
- a pr ogr am t hat det er mines t he nat ur e of t he
int er r upt and per f or ms what ever act ions ar e needed
- gener ally par t of t he oper at ing syst em
12
I nt er r upt Cycle
- Pr ocessor checks f or int er r upt s
- I f no int er r upt s f et ch t he next inst r uct ion f or t he
cur r ent pr ogr am
- I f an int er r upt is pending, suspend execut ion of t he
cur r ent pr ogr am, and execut e t he int er r upt handler
13
Cont r ol f low wit h int er r upt s
14
What happens
(a) St eps in st art ing an I / O device and get t ing int errupt (b) How t he CPU is int errupt ed
(a) (b)
15
I nt er r upt s as suppor t f or I / O
Not e:
- I nt er r upt s allow t he pr ocessor t o execut e ot her
inst r uct ions while an I / O oper at ion is in pr ogr ess
- I mpr ove pr ocessing ef f iciency
16
I nt er r upt -Dr iven I / O
- Pr ocessor is int er r upt ed when I / O
module r eady t o exchange dat a
- Pr ocessor is f r ee t o do ot her wor k
- No needless wait ing
BUT:
- St ill consumes a lot of pr ocessor
t ime because ever y wor d r ead or wr it t en passes t hr ough t he pr ocessor How about using DMA …
17
I / O using Dir ect Memor y Access (DMA)
- The pr ocessor is only involved at
t he beginning and end of t he t r ansf er
– Pr ocessor gr ant s I / O (DMA) module aut hor it y t o r ead f r om or wr it e t o memor y a block of dat a – An int er r upt is sent when t he t ask is complet e
- Pr ocessor is f r ee t o do ot her
t hings
18
Mult iple I nt er r upt s Q: To int er r upt an int er r upt ?
1. Sequent ial Or der : af t er int er r upt handler complet es, pr ocessor checks f or addit ional int er r upt s 2. Pr ior it ies: High pr ior it y int er r upt s:
- cause lower -pr ior it y
int er r upt s t o wait – cause a lower -pr ior it y int er r upt handler t o be int er r upt ed – Example: when input ar r ives f r om communicat ion line, it needs t o be absor bed quickly t o make r oom f or mor e input
19
Comput er Hardware Review (7)
St ruct ure of a large Pent ium syst em
20
Cache Memory
- I ncrease t he speed of memory
– Pr ocessor speed is higher t han memor y speed
Hit : t he inf ormat ion was in cache; else, miss
- I nvisible t o operat ing syst em
21
Cache Design: I mpor t ant issues
- 1. Cache size
- 2. Block size
- 3. Mapping f unct ion
- det ermines which cache locat ion t he
block will occupy
- 4. Replacement algorit hm
- det ermines which block t o replace
(e.g. Least -Recent ly-Used (LRU) algorit hm)
- 5. Writ e policy
- Can occur every t ime block is updat ed
- Can occur only when block is replaced
– Minimizes memory operat ions – Leaves memory in an obsolet e st at e
22
Memor y Hier ar chy
Going Down t he Hier ar chy
- I ncr easing capacit y, I ncr easing access
t ime
- Decr easing cost per bit , Decr easing
f r equency of access of t he memor y
– localit y of ref erence: during program execut ion memory addresses t end t o clust er (it erat ion loops, subrout ines, … )
Operat ing Syst em Overview
24
Layers of Comput er Syst em
25
Oper at ing Syst em – OS obj ect ives
- Pr ovides a set of ser vices
t o syst em user s
- Shield bet ween t he user
and t he har dwar e
- Resour ce manager :
– CPU(s) – memor y and I / O devices
- Convenience
– Makes t he comput er mor e convenient t o use
- Ef f iciency
– Allows comput er syst em r esour ces t o be used in an ef f icient manner
- Abilit y t o evolve
– Per mit int r oduct ion of new syst em f unct ions wit hout int er f er ing wit h ser vice
26
Ser vices Pr ovided by t he Oper at ing Syst em
- Pr ogr am execut ion:
– CPU scheduling, resource (memory) allocat ion and management , synchronizat ion
- Access t o I / O devices
– Unif orm int erf aces, hide det ails, opt imise resources (disk scheduling)
- Cont r olled access t o f iles
– And st ruct ure of dat a
- Syst em/ r esour ce access
– Aut horizat ion, prot ect ion, allocat ion
- Ut ilit ies, e.g. f or pr ogr am development
– Edit ors, compilers, debuggers
- Er r or det ect ion and r esponse, when, e.g.
– hardware, sof t ware errors – operat ing syst em cannot grant request of applicat ion
- Monit or ing, account ing
27
Oper at ing Syst em: … (r oughly) it is a pr ogr am …
- r elinquishes
cont r ol of t he pr ocessor t o execut e ot her pr ogr ams OS Ker nel:
- (r oughly) por t ion
- f OS t hat is in
main memor y
- Cont ains most -
f r equent ly used f unct ions
28
Some hist or y: Evolut ion of Oper at ing Syst ems
- Har dwar e upgr ades, new t ypes of har dwar e, enabled
f eat ur es
- New ser vices, new needs
29
OS hist ory: bef ore t he st one age
Ser ial Pr ocessing
- No oper at ing syst em
- Machines r un f r om a console wit h display light s and
t oggle swit ches, input device, and pr int er
- Schedule t ome
- Set up included
– loading t he compiler , sour ce pr ogr am, – saving compiled pr ogr am – loading – linking
30
OS hist or y: f ir st “t ools” appear Simple Bat ch Syst ems:
- Monit or s
– Sof t war e t hat cont r ols t he r unning pr ogr ams – Bat ch j obs t oget her – Pr ogr am br anches back t o monit or when f inished – Resident monit or is in main memor y and available f or execut ion
- J ob Cont r ol Language (J CL)
– Pr ovides inst r uct ion t o t he monit or
- what compiler t o use
- what dat a t o use
31
OS hist or y: Har dwar e Feat ur es…
… which made t he f irst t ools possible:
- Memor y pr ot ect ion
– do not allow t he memor y ar ea cont aining t he monit or t o be alt er ed
- Pr iviledged inst r uct ions
– Only f or monit or, e.g. f or int erf ace wit h I / O devices
- I nt er r upt s
– Mechanisms f or t he OS t o r elinquish cont r ol and r egain it
- Timer
– pr event s a j ob f r om monopolizing t he syst em
32
OS hist or y: Uni/ mult i-pr ogr amming
f rom uniprogramming… .
Pr ocessor must wait f or I / O inst r uct ion t o complet e bef or e pr oceeding
… t o Mult iprogramming
When one j ob needs t o wait f or I / O, t he pr ocessor can swit ch t o t he ot her j ob
33
Early bat ch syst em
– bring cards t o 1401 – read cards t o t ape – put t ape on 7094 which does comput ing – put t ape on 1401 which print s out put
34
OS hist or y: Mult ipr ogr amming, Time Shar ing Time shar ing syst ems use mult ipr ogr amming t o handle mult iple int er act ive j obs
- Pr ocessor’s t ime is shar ed among mult iple user s
- Mult iple user s simult aneously access t he syst em
t hr ough t er minals
Batch Multiprogramming Time Sharing Principal objective Maximize processor use Minimize response time Source of directives to
- perating system
Job control language commands provided with the job Commands entered at the terminal
35
OS hist or y: mult ipr ogr amming needs …
- …
memor y management !
36
Summary: evolut ion
- First generat ion 1945 - 1955
– vacuum t ubes, plug boards
- Second generat ion 1955 - 1965
– t ransist ors, bat ch syst ems
- Third generat ion 1965 – 1980
– I Cs and mult iprogramming
- Fourt h generat ion 1980 – present
– personal comput ers
- More cont emporary present :
– Personal comput ers become parallel
37
Zooming in a f ew key services The main j ob of OS is t o: run processes! ...
38
Process:t he concept
Pr ocess = a pr ogr am in execut ion
- Example pr ocesses:
– OS ker nel – OS shell – Pr ogr am execut ing af t er compilat ion – www-br owser
39
Process: I mplement at ion Consist s of t hree component s
- An execut able program
- Associat ed dat a needed
by t he program
- Execut ion cont ext of
t he program
– All inf or mat ion t he
- per at ing syst em needs t o
manage t he pr ocess
Execut ion cont ext
- f t he pr ogr am
40
Processes creat e ot her processes
- A process t ree
– A (e.g. shell) creat ed t wo child processes, B (e.g. browser) and C (print ) – B creat ed t hree child processes, D, E, and F (various browser services/ windows)
41
Procs need: synchronizat ion, ...
Two processes connect ed by a pipe
42
… , t o get CPU t ime and ot her resources, …
Goals when allocat ing r esour ces t o pr ocesses:
- Fair ness and Dif f er ent ial r esponsiveness
– give f air access t o all pr ocesses – discr iminat e bet ween dif f er ent classes of j obs
- Ef f iciency
– maximize t hr oughput , minimize r esponse t ime, and accommodat e as many user s as possible
43
... t o get resources wit hout deadlock, ... (a) A pot ent ial deadlock. (b) an act ual deadlock.
44
..., t o do I O, access f iles, ...
I mport ant issues:
- Organizat ion of inf ormat ion
- Ef f icient access
45
… , t o get memory
Memory Management
I mpor t ant issues:
- Pr ocess isolat ion
– Pr event int er f er ence bet ween dif f er ent pr ocesses – Pr ot ect ion and access cont r ol when shar ing memor y
- Allocat ion
– Cr eat e, dest r oy modules dynamically – Suppor t f or modular pr ogr amming – Ef f iciency, good ut ilizat ion
46
Virt ual Memory
- Allows pr ogr ammer s t o addr ess memor y f r om a logical
point of view (wit hout wor r ying about t he physical availabilit y)
- Tr ansf er memor y disk: t r anspar ent t o t he
pr ocesses
47
Maj or Element s of an Operat ing Syst em
- OS = ver y lar ge piece of
sor t war e!
- Component s: decompose a
pr oblem int o mor e manageable subpr oblems (pr ocess manager , f ile manager , et c)
- Boot st r ap pr ogr am act ivat es
OS ker nel (per manent syst em pr ocess)
– Shell ( kernel): program t o let t he user init iat e processes
- User or syst em pr ogr ams
make dir ect use of t he OS via syst em calls
48
St eps in Making a Syst em Call
st eps in making t he syst em call
read (fd, buffer, nbytes)
49
Some Syst em Calls
50
A st ripped down shell
while (TRUE) { /* repeat forever * / type_prompt( ); /* display prompt * / read_command (command, parameters) /* input from terminal * / if (fork() != 0) { /* fork off child process * / /* Parent code * / waitpid( -1, &status, 0); /* wait for child to exit * / } else { /* Child code * / execve (command, parameters, 0); /* execute command * / } }
51
52
I ssues in Modern Operat ing Syst ems
- Micr oker nel ar chit ect ur e
– Only f ew essent ial f unct ions in ker nel; OO design
- Mult it hr eading
– A pr ocess may consist of sever al sequent ial t hr eads of execut ion
- Concur r ent comput er syst ems
– Symmet r ic mult i-pr ocessor syst ems – Mult i-t hr eaded/ mult icor e pr ocessor s – Dist r ibut ed syst ems
- provide t he illusion of a single main memory and single
secondary memory space in clust er-based plat f orms
- Real-t ime Oper at ing Syst ems
– For t ime-cr it ical applicat ions, mult imedia, …
- Embedded Oper at ing Syst ems
– Const r aint s: limit ed r esour ces, special f unct ionalit ies
53
Microkernel
- Small OS cor e; cont ains only essent ial OS f unct ions:
– Low-level memory management (address space mapping) – Process scheduling – I / O and int errupt management
- Many ser vices t r adit ionally included in t he OS ker nel ar e now
ext er nal subsyst ems
– device drivers, f ile syst ems, virt ual memory manager, windowing syst em, securit y services
54
Benef it s of a Microkernel Organizat ion
- Unif or m int er f ace on r equest made by a pr ocess
– All services are provided by means of message passing
- Dist r ibut ed syst em suppor t
– Message are sent wit hout knowing what t he t arget machine is
- Ext ensibilit y
– Allows t he addit ion/ removal of services and f eat ures
- Por t abilit y
– Changes needed t o port t he syst em t o a new processor is changed in t he microkernel - not in t he ot her services
- Obj ect -or ient ed oper at ing syst em
– Component s are obj ect s wit h clearly def ined int erf aces t hat can be int erconnect ed
- Reliabilit y
– Modular design; – Small microkernel can be rigorously t est ed
55
Concurrent Comput er Syst ems
each instruction executed on a dif f erent set of data by the dif f erent processors a set of processors simultaneously execute dif f erent instruction sequences on dif f erent data sets
56
Symmet ric Mult iprocessors (and mult icores)
- Pr ocessors shar e t he same memor y and I / Os
- Ker nel can execut e on any pr ocessor
- Scheduling & synchr onizat ion, memor y management &
consist ency (also r esear ch issues)
57
Clust er Comput er Plat f orms
- Net wor k
- Middlewar e layer (par t of OS) t o pr ovide
– single-syst em image (synchr onizat ion, consist ency, global st at es, f ile syst ems) – f ault -t oler ance, load balancing, par allelism
58
I nst ant iat ion: UNI X
- Har dwar e is sur r ounded by t he oper at ing-syst em
- Oper at ing syst em is called t he ker nel
- Moder n unix ver sions (solar is) mor e complex
- Comes wit h a number of user ser vices and int er f aces
– Shell, compiler s, …
59
I nst ant iat ion: Windows
- Client / Ser ver
comput ing; base f or dist r ibut ed comput ing
- Modif ied micr oker nel
ar chit ect ur e
– not a pur e micr oker nel: many syst em f unct ions
- ut side of t he