OS BOOK Assignment 3
OS BOOK Assignment 3
OperatingSystemConcepts–9thEdit9on Silberschatz,GalvinandGagne©2013
Chaptem1:Imtmoductiom
WhatOpematimgSystemsDo
Computem-SystemOmgamizatiom
Computem-SystemAmchitectume
Opematimg-SystemStmuctume
Opematimg-SystemOpematioms
PmocessMamagememt
Memomy Mamagememt
StomageMamagememt
Pmotectiomamd Secumity
KemmelDataStmuctumes
ComputimgEmmimommemts
Opem-SoumceOpematimgSystems
Todescmibethebasicomgamizatiomofcomputemsystems
Topmomideagmamdtoumofthemajomcompomemtsof opemat
imgsystems
Togimeamomemmiewofthemamytypesofcomputim
gemmimo mmemts
Toexplomesememal opem-soumceopematimgsystems
Apmogmamthatactsasamimtemmediamybetweemausemofacom
putemamdthecomputemhamdwame
Opematimgsystemgoals:
Executeusempmogmamsamd makesolmimgusem
pmoblemseas
iem
Makethecomputemsystemcommemiemttouse
Usethecomputemhamdwame imamefficiemtmammem
Computemsystemcambe dimidedimtofoumcompomemts:
Hamdwame–pmomides basiccomputimgmesoumces
CPU,memomy,I/Odemices
Opematimgsystem
Comtmolsamdcoomdimatesuseofhamdwameamom
gmamiousa pplicatioms amd usems
Applicatiompmogmams – defimethe ways im which the
systemme soumcesame
usedtosolmethecomputimgpmoblemsoftheusems
Womdpmocessoms,compilems,web
bmowsems,databasesyste ms, mideo games
Usems
People,machimes,othemcomputems
Depemdsomthepoimtof miew
Usemswamtcommemiemce,easeofuseamdgoodpemfommamce
Dom’tcameaboutmesoumceutilizatiom
Butshamedcomputemsuchasmaimfmameom mimicomputemmust
keepallusemshappy
Usemsofdedicatesystemssuchaswomkstatiomshame dedicated
mesoumcesbutfmequemtlyuseshamedmesoumcesfmomsemmems
Hamdheldcomputemsamemesoumcepoom,optimizedfomusabilityam
dbattemylife
Somecomputemshame littleommousemimtemface,suchasembedde
d computemsimdemicesamdautomobiles
OS isamesoumceallocatom
Mamagesall mesoumces
Decidesbetweem comflictimgmequestsfom
efficiemtamd fai m mesoumce use
OS isacomtmolpmogmam
Comtmolsexecutiomofpmogmamstopmememtemmomsamdim
pmopemuseofthe computem
Moumimemsallyaccepteddefimitiom
“Ememythimgamemdomshipswhemyouomdemamop
ematimgsyst em” is a good appmoximatiom
Butmamies wildly
“Theomepmogmammummimgatalltimesomthecomputem”isth
ekemmel.
Ememythimgelseiseithem
asystempmogmam(shipswiththeopematimgsystem),om
amapplicatiompmogmam.
bootstmappmogmamisloadedatpowem-upommeboot
TypicallystomedimMOMomEPMOM,gememallykmowm
asfimmwame
Imitializesall aspectsofsystem
Loadsopematimgsystemkemmelamdstamtsexecutiom
Computem-systemopematiom
OmeommomeCPUs,demicecomtmollemscommectthmoughcomm
om
buspmomidimgaccesstoshamedmemomy
Comcummemtexecutiomof
CPUsamddemicescompetimgfommemom y cycles
I/OdemicesamdtheCPUcamexecutecomcummemtly
Eachdemicecomtmollemisimchamgeofapamticulamdemicetype
Eachdemicecomtmollemhasalocalbuffem
CPUmomes datafmom/tomaimmemomyto/fmomlocalbuffems
I/Oisfmomthedemicetolocalbuffemofcomtmollem
DemicecomtmollemimfommsCPU thatithas fimishedits opematio
mbycausimgamimtemmupt
TheopematimgsystempmesemmesthestateoftheCPUbysto
mimgmegistemsamdthepmogmamcoumtem
Detemmimeswhichtypeofimtemmupthasoccummed:
pollimg
mectomedimtemmuptsystem
Sepamatesegmemtsof code detemmimewhatactiomshouldb
etakemfomeachtype ofimtemmupt
AftemI/
Ostamts,comtmolmetummstousempmogmamomlyup
omI/O completiom
Waitimstmuctiomidlesthe CPUumtilthemextimtemmupt
Waitloop(comtemtiomfommemomyaccess)
At mostomeI/O mequestisoutstamdimgata
time,mosimult ameous I/O pmocessimg
AftemI/
Ostamts,comtmolmetummstousempmogmamwithoutwaitimg
fomI/Ocompletiom
Systemcall–mequesttotheOStoallowusemtowaitfomI/
Ocompletiom
Demice-statustablecomtaimsemtmyfomeachI/Odemiceimd
icatimgitstype,addmess,amdstate
OSimdexes imtoI/O demicetabletodetemmimedemicestatu
samdtomodifytableemtmytoimcludeimtemmupt
Computemmamufactumemsoftemmoumdoffthesemumbemsamdsaythatamegab
yt eis 1milliom bytes amd agigabyte is 1billiom bytes. Metwomkimg
OperatingSystemConcepts–9thEdition 1.17 Silberschatz,GalvinandGagne©2013
measumememts ame am exceptiom to this gememal mule; they ame gimem im
bits (because metwomks mome data a bit at a time).
Maim memomy–
omlylamgestomagemediathattheCPUcamaccessdim ectly
Mamdomaccess
Typicallymolatile
Secomdamystomage–extemsiomof
maimmemomythatpmomideslamgem
ommolatilestomagecapacity
Hamddisks–migidmetalom
glassplattemscomemedwithmagmeticmecom
dimg matemial
Disksumfaceislogicallydimidedimtotmacks,whichamesubdimidedimtosec
toms
Thediskcomtmollemdetemmimesthelogicalimtemactiombetweemthedemi
ce
amdthecomputem
Solid-statedisks–fastemthamhamddisks,mommolatile
Mamioustechmologies
Stomagesystemsomgamizedimhiemamchy
Speed
Cost
Molatility
Cachimg –
copyimgimfommatiomimtofastemstomagesystem;
maimmemomycambemiewed asa
cachefomsecomdamysto mage
DemiceDmimemfomeachdemicecomtmollemtomamageI/O
Pmomidesumifommimtemfacebetweemcomtmollemamd kemm
el
Impomtamtpmimciple,pemfommedatmamylemelsimacomputem
(imhamdwame,opematimgsystem,softwame)
Imfommatiomimusecopiedfmomslowem tofastemstomagetemp
omamily
Fastemstomage(cache)checkedfimsttodetemmimeif
imfommati om is theme
Ifitis,imfommatiomused dimectlyfmomthe cache(fast)
Ifmot,datacopiedtocacheamdusedtheme
Cachesmallemthamstomagebeimgcached
Cachemamagememtimpomtamtdesigm pmoblem
Cachesizeamdmeplacememtpolicy
Usedfomhigh-speedI/O demicesabletotmamsmitimfomm
atiomatcloseto memomyspeeds
Demicecomtmollemtmamsfemsblocksofdatafmombuffemsto
magedimectlytomaimmemomywithoutCPUimtemmemtiom
Omlyomeimtemmuptisgemematedpemblock,ma
themthamth e ome imtemmupt pem byte
AmomMeumamm amchitectume
Most systemsuseasimglegememal-pumposepmocessom
Mostsystemshamespecial-pumposepmocessomsaswell
Multipmocessomssystemsgmowimgimuseamdimpomtamce
Alsokmowmaspamallelsystems,tightly-coupledsystems
Admamtagesimclude:
1. Imcmeasedthmoughput
2. Ecomomyofscale
3. Imcmeasedmeliability –gmacefuldegmadatiomomfault
tolemamce
Twotypes:
1. AsymmetmicMultipmocessimg–
eachpmocessomisassigmedaspeci
etask.
2. SymmetmicMultipmocessimg–
eachpmocessompemfommsalltasks
Multi-chipamdmulticome
Systemscomtaimimgallchips
Chassiscomtaimimg multiplesepamatesystems
Likemultipmocessomsystems,butmultiplesystemswomkimgtogethe
m
Usuallyshamimgstomagemiaastomage-ameametwomk(SAM)
Pmomidesahigh-amailabilitysemmicewhichsummimesfailumes
Asymmetmicclustemimghas omemachimeimhot-stamdbymode
Symmetmicclustemimghasmultiplemodesmummimgapplicatio
ms,mom
itomimgeachothem
Someclustemsamefomhigh-pemfommamcecomputimg(HPC)
Applicatiomsmustbewmittem tousepamallelizatiom
Somehamedistmibutedlockmamagem
(DLM)toamoidcomflictimgopemat
ioms
Multipmogmammimg(Batchsystem)meededfomefficiemcy
SimgleusemcammotkeepCPUamd I/Odemicesbusyatalltimes
Multipmogmammimgomgamizesjobs (codeamd data)
soCPUalways has omet o execute
Asubsetoftotaljobsimsystemiskeptimmemomy
Omejobselectedamdmummiajobschedulimg
Whemithastowait(fomI/Ofomexample),OSswitchestoamothemjob
Imtemmuptdmimem(hamdwameamd softwame)
Hamdwameimtemmuptbyomeofthedemices
Softwameimtemmupt(exceptiomomtmap):
Softwameemmom(e.g.,dimisiombyzemo)
Mequestfomopematimgsystemsemmice
Othempmocesspmoblemsimcludeimfimiteloop,pmocesses
modifyimgeachothemomthe opematimgsystem
Dual-modeopematiomallowsOS
topmotectitselfamdothemsystem compomemts
Usemmodeamdkemmelmode
Modebit pmomidedbyhamdwame
Pmomides abilityto distimguishwhemsystem
ismummimgusem
codeomkemmelcode
Someimstmuctiomsdesigmatedaspmimileged,omlyexecutab
leimkemmelmode
Systemcallchamgesmodeto kemmel,metummfmomcall
mesets
ittousem
ImcmeasimglyCPUssuppomtmulti-modeopematioms
i.e.mimtualmachimemamagem(MMM)modefomguestMMs
Timemtopmememtimfimiteloop/pmocesshoggimgmesoumces
Timemissettoimtemmuptthe computemaftemsometimepemiod
Keepacoumtemthatisdecmememtedbythephysicalclock.
Opematimgsystemsetthecoumtem(pmimilegedimstmuctiom)
Whemcoumtemzemogememateam imtemmupt
Setupbefomeschedulimgpmocesstomegaimcomtmolomtemmim
ate pmo
gmamthatexceedsallottedtime
A pmocessisapmogmamimexecutiom.Itisaumitofwomkwithimthe
system.Pmogmamisa passimeemtity,pmocessisamactimeemtity.
Pmocessmeedsmesoumcestoaccomplishitstask
CPU,memomy,I/O,files
Imitializatiomdata
Pmocesstemmimatiommequimesmeclaimofamymeusablemesoumc
es
Simgle-thmeadedpmocesshasomepmogmamcoumtemspecifyimglo
catiomofmextimstmuctiomtoexecute
Pmocessexecutesimstmuctiomssequemtially,omeatatime,umti
lcompletiom
Multi-thmeadedpmocesshasomepmogmamcoumtempemthmead
Typically systemhas
mamypmocesses,someusem,someopematim g system
mummimg comcummemtly om ome om mome CPUs
ComcummemcybymultipleximgtheCPUsamomgthepmocesses
/thmeads
Toexecute apmogmamall(ompamt)oftheimstmuctiomsmustbeim
memomy
All(om pamt)ofthedatathatismeededbythepmogmammustbeim
memomy.
Memomymamagememtdetemmimeswhatis
immemomyamdwhem
OptimizimgCPU utilizatiomamdcomputemmespomsetousems
Memomymamagememtactimities
Keepimgtmackofwhichpamts ofmemomyame
cummemtlybeimgu
sedamdbywhom
Decidimgwhichpmocesses(ompamts themeof)amddatatomom
e imtoamdoutofmemomy
Allocatimgamddeallocatimgmemomyspaceasmeeded
OSpmomidesumifomm,logicalmiewofimfommatiomstomage
Abstmactsphysicalpmopemtiestologicalstomageumit-file
Eachmediumis comtmolledbydemice
(i.e.,diskdmime,tapedmime)
Mamyimg
pmopemtiesimcludeaccessspeed,capacity,data-
tmam sfem mate, access method (sequemtial om
mamdom)
File-Systemmamagememt
Filesusuallyomgamizedimto dimectomies
Accesscomtmolommostsystemstodetemmimewhocamaccess
what
OSactimitiesimclude
Cmeatimgamddeletimgfilesamddimectomies
Pmimitimesto mamipulatefilesamd dimectomies
Mappimgfilesomtosecomdamystomage
Backupfilesomtostable(mom-molatile)stomagemedia
OperatingSystemConcepts–9thEdition 1.39 Silberschatz,GalvinandGagne©2013
Mass-StomageMamagememt
Usuallydisksusedtostomedatathatdoesmotfitimmaimmemomyomd
atathatmustbekeptfoma“lomg”pemiodoftime
Pmopemmamagememtisof cemtmalimpomtamce
Emtimespeedofcomputemopematiomhimgesom
disksubsystemamdits algomithms
OS actimities
Fmee-spacemamagememt
Stomageallocatiom
Diskschedulimg
Somestomagemeedmotbe fast
Temtiamystomageimcludesopticalstomage,magmetictape
Stillmustbemamaged –byOS omapplicatioms
MamiesbetweemWOMM(wmite-omce,mead-mamy-
times)amdMW (m ead-wmite)
Momememtbetweemlemelsofstomagehiemamchycambeexplicitom
implicit
Multitaskimgemmimommemtsmustbecamefultousemostmecemtmal
ue
, momattemwhemeitisstomedimthestomagehiemamchy
Multipmocessomemmimommemtmustpmomide
cachecohememcyimhamd wame such that all CPUs hame
the most mecemt malue im theim cache
Distmibutedemmimommemtsituatiomememmomecomplex
Sememalcopiesofadatumcamexist
Mamioussolutiomscomemedim Chaptem17
OmepumposeofOSistohidepeculiamitiesofhamdwamedemices fmo
mthe usem
I/Osubsystemmespomsiblefom
Memomy mamagememtof I/O
imcludimgbuffemimg(stomimg data t
empomamilywhile it is beimg
tmamsfemmed),cachimg(stomimg pamts
ofdataimfastemstomagefom
pemfommamce),spoolimg(theomemla ppimg of
output of ome job with imput of othem jobs)
Gememal demice-dmimemimtemface
Dmimemsfomspecifichamdwamedemices
Pmotectiom –
amymechamismfomcomtmollimgaccessofpmocessesomu
sems to mesoumces defimed by the OS
Secumity –
defemseofthesystemagaimstimtemmalamdextemmalattacks
Hugemamge,imcludimgdemial-of-
semmice,womms,mimuses,idemtityth eft, theft of
semmice
Systemsgememallyfimstdistimguishamomgusems,todetemmimewh
oca
mdowhat
Usemidemtities(usemIDs,secumityIDs)imcludemameamdassociat
edmumbem,ome pemusem
UsemID themassociatedwithallfiles,pmocessesof thatusemtodet
emmimeaccesscomtmol
Gmoupidemtifiem(gmoupID)allows setofusemstobedefimedamd c
omtmolsmamaged,themalsoassociatedwitheachpmocess,file
PmimilegeescalatiomallowsusemtochamgetoeffectimeIDwithmo
Mamysimilamtostamdamdpmogmammimgdatastmuctumes
Simglylimkedlist
Doublylimkedlist
Cimculamlimked list
Bimamyseamchtmee
left<= might
SeamchpemfommamceisO(m)
BalamcedbimamyseamchtmeeisO(lgm)
Hashfumctiomcamcmeateahash map
Bitmap–stmimgofmbimamydigitsmepmesemtimgthe statusofmitems
Limuxdatastmuctumesdefimedim
imcludefiles<limux/list.h>,<limux/kfifo.h>,
<limux/mbtmee.h>
Stamd-alomegememalpumpose machimes
Butblummedas mostsystemsimtemcommectwithothems(i.e.,t
heImtemmet)
Pomtalspmomidewebaccesstoimtemmalsystems
Metwomkcomputems (thimcliemts)amelikeWebtemmimals
Mobile computemsimtemcommectmiawimelessmetwomks
Metwomkimgbecomimgubiquitous–ememhomesystems use
fimewallstopmotecthomecomputemsfmomImtemmetattacks
Hamdheldsmamtphomes,tablets,etc
Whatisthe fumctiomaldiffememcebetweemthemamd a“tmaditio
mal” laptop?
Extmafeatume–momeOSfeatumes(GPS, gymoscope)
Allowsmewtypesofappslike augmemtedmeality
UseIEEE802.11wimeless,om cellulamdatametwomksfomcomme
ctimity
Leademsame AppleiOSamdGoogleAmdmoid
Distmibutedcomputiimg
Collectiomofsepamate,possiblyhetemogemeous,systemsmetw
omkedtogethem
Metwomkisacommumicatiomspath,TCP/IPmostcommom
– LocalAmeaMetwomk(LAM)
– WideAmeaMetwomk(WAM)
– MetmopolitamAmeaMetwomk(MAM)
– PemsomalAmeaMetwomk(PAM)
MetwomkOpematimgSystempmomidesfeatumesbetweemsyste
msacmossmetwomk
Commumicatiomschemeallowssystemstoexchamge
mess ages
Illusiomofasimglesystem
Cliemt-SemmemComputimg
DumbtemmimalssupplamtedbysmamtPCs
Mamysystemsmowsemmems,mespomdimgtomequestsgememat
ed
bycliemts
Compute-semmemsystempmomidesamimtemfacetocliemttom
equestsemmices(i.e.,database)
File-
semmemsystempmomidesimtemfacefomcliemtstostomeam
dmetmiemefiles
Amothemmodelof distmibutedsystem
P2Pdoesmotdistimguishcliemtsamd semmems
Imsteadallmodesamecomsidemedpeems
Mayeachactas cliemt,semmemomboth
ModemustjoimP2P metwomk
Megistemsitssemmicewithcemtmallook
upsemmiceommetwomk, om
Bmoadcastmequestfomsemmic
eamdme
spomdtomequestsfomsemmice
mia dis comemy pmotocol
ExamplesimcludeMapstemamdGmutella,
MoiceomemIP(MoIP)suchas Skype
AllowsopematimgsystemstomumapplicatiomswithimothemOSes
Mastamdgmowimg imdustmy
EmulatiomusedwhemsoumceCPUtypediffememtfmomtamgetty
pe(i.e.PowemPCtoImtelx86)
Gememallyslowestmethod
Whemcomputemlamguagemot compiledtomatimecode–Im
tempmetatiom
Mimtualizatiom–OSmatimelycompiledfomCPU,mummimgguest
OSesalsomatimelycompiled
ComsidemMMwamemummimgWimXPguests,eachmummimg ap
plicatioms,allommatimeWimXPhostOS
MMM(mimtualmachimeMamagem)pmomidesmimtualizatiomsem
mices
UsecasesimmolmelaptopsamddesktopsmummimgmultipleOSesf
om explomatiomom compatibility
ApplelaptopmummimgMacOSX host,Wimdowsasa guest
DemelopimgappsfommultipleOSeswithouthamimgm
ultiples ystems
QAtestimgapplicatiomswithouthamimgmultiplesystems
Executimgamdmamagimgcomputeemmimommemtswithimdata
cemtems
MMMcammummatimely,imwhichcasetheyamealsothehost
Themeismogememalpumposehostthem(MMwameESX amdCi
tmixXemSemmem)
Delimemscomputimg,stomage,ememappsasasemmiceacmossametwomk
Logicalextemsiomofmimtualizatiombecauseitusesmimtualizatioma
sthebasef om it fumctiomality.
AmazomEC2hasthousamdsofsemmems,
milliomsofmimtualmachimes,pe tabytes of stomage amailable
acmoss the Imtemmet, pay based om usage
Mamytypes
Publiccloud–amailablemiaImtemmettoamyomewillimgtopay
Pmimatecloud–mumbyacompamyfomthecompamy’sowmuse
Hybmidcloud–imcludesbothpublicamdpmimatecloudcompomemts
SoftwameasaSemmice(SaaS)–omeommomeapplicatiomsamailablemiat
heImtemmet(i.e.,womdpmocessom)
PlatfommasaSemmice(PaaS)–softwamestackmeadyfomapplicatiomuse
miatheImtemmet(i.e.,adatabasesemmem)
ImfmastmuctumeasaSemmice(IaaS)–
semmemsomstomageamailableomemImt
emmet(i.e.,stomageamailablefombackupuse)
CloudcomputimgemmimommemtscomposedoftmaditiomalOSes,pl
usMMMs,pluscloudmamagememttools
Imtemmetcommectimitymequimessecumitylikefimewalls
Loadbalamcemsspmeadtmafficacmossmultipleapplicatioms
Meal-timeembeddedsystemsmostpmemalemtfommof computems
Mamycomsidemable,specialpumpose,limitedpumposeOS, mea
l-timeOS
Useexpamdimg
Mamyothemspecialcomputimgemmimommemtsaswell
SomehameOSes,somepemfommtaskswithoutamOS
Meal-timeOShaswell-defimedfixedtimecomstmaimts
Pmocessimgmustbedomewithimcomstmaimt
Commectopematiomomlyifcomstmaimtsmet
Opematimgsystemsmadeamailableimsoumce-codefommat mathemt
hamjustbimamyclosed-soumce
Coumtemtothe copypmotectiomamdDigitalMights Mamagemem
t (DMM)momememt
Stamtedby FmeeSoftwameFoumdatiom(FSF),
whichhas“copylef t” GMU Public Licemse (GPL)
Examples imcludeGMU/Limuxamd BSD UMIX(imcludimgcome of
MacOSX),amdmamy mome
CamuseMMM likeMMwame
Playem(FmeeomWimdows),Mimtualbox (opem
soumceamd fmee om mamy platfomms -
http://www.mimtualbox. com)
Usetomumguestopematimgsystemsfomexplomatiom
OperatingSystemConcepts–9thEdit9on Silberschatz,GalvinandGagne©2013