You are on page 1of 10

3.

5
hrsremaining
Alsoputa*nexttoanyquestionyoufeelisveryimportant(e.g.ConditionsforDeadlock)

Cheat sheet, anyone?


https://docs.google.com/file/d/0B1buYWv16VodS2c0dm5yMjJfTDg/edit
Note: this is from last semester, but everything is relevant and covered as far as I know :)
^Great, but just remember not to copy directly from this when writing the exam, because
then everyone would have very similar answers, which would be a problem.
How da hell did that person fit all of that into two pages, I could fit only half that content.
sweet mother teresa bet they probably didnt even need to look at it lol
That was one amazing cheat sheet...
------------OperatingSystems(general)
Whydowehaveoperatingsystems?Whatistheirpurpose?
Interfacebetweencodeandhardware
Manageslimitedresources:CPU,Memory,Peripherals
Whattradeoffsdooperatingsystemdesignersneedtomake?
- Efficiencies: Time VS Space
- Levels of abstraction (User level, Kernel Level, etc)
- Measures of privacy (strictness of permissions)

design
principlesguidethedevelopmentofanoperatingsystem?

What
-

Be as transparent as possible, work concurrently seamlessly, virtualize like a


mofo, be persistent (data storage) cuz otherwise...

Processes&Threads
Whatisaprocess?Whatisathread?
Process:abstractionforexecution.
a program in execution
,virtualizationofCPU
Thread:
a program counter, stack and register all bundled together for

different paths of execution in a process


Whatisthedifferencebetweenuserlevelthreadsandkernellevelthreads?
- The OS knows nothing about user-level threads, more overhead users know
nothing about kernel-level threads, are heavily dependent on the OS
Howarenewprocessescreated?Controlled?Deleted?

new entry inserted into the process table assign memory for code, kernel stack,

local stack, heap process represented by PCB (process control block) with stuff

like PID, POSIX times, pointers (i think?)not sure how stuff is deleted tho

Concurrency
Synchronizationprimitives
Softwaresolutions
Ithink::lock,semaphores,conditionvariables,monitors..
??(Whatarethesoftwaresolutions??)Anyreadingsonthis?
Aretheselike..yield
commands?
Hardwareinstructions
Disableinterrupts(whichonlyworksforuniprocessormachine)
multiprocessorsmachineismorecomplextodealwith
Semaphores
aninteger
properties:initialvalueonlychangeableunder
wait():blocktillitspositionandthendecrement
orsignal():incrementsemaphoretillitspositiveandwakeupblockedthreads
semaphoreoperationsare
atomic
checkitsvalueandgobacktosleepifitsnegative

Locks
Lockproperties:
Mutualexclusion(correctness):onlyonethreadcanbeinthecriticalsection(oraccess
thecriticaldata,whichisthesharedresource)
Fairness
Performance
nostarvation

Monitors
THIS IS NOT ON THE EXAM
Confirmed in the Review Session on Friday.

Thanks!(keepthishereanywaysforeveryoneelsetoknow)

Deadlock
***Conditionsfordeadlock
-
MUTUAL EXCLUSION
: threads claim exclusive control of required resources.
-
HOLD&WAIT
: Threads hold resources and wait for additional resources
-
NO PREEMPTION
: u cant rip resources out of a threads hands like candy from baby
-
CIRCULAR WAIT
: theres a chain of resources such that one threads holding a
resource that another thread needs so like T1 has R1 but needs R2, T2 has R2 but
needs R3, T3 has R3 but needs etc
*does anyone know how many of these need to be true in order for deadlock to be
possible? def not just one pls respond (
ANSWERED DIRECTLY BELOW)

Prevention
pretty sure that as long as you dont have all 4, deadlock cannot happen. just answered my
own question above lol
yep confirmed

Avoidance
Detection&recovery

Scheduling
Goalsindevelopingagoodschedulingalgorithm
- fairness, maximize response time, minimize turnaround time, no starvation, probably
a few others
IsawthebatchoneinoneofthefinalssoIlljustaddthemhere
BATCH:throughput(maximize#ofjobs),turnaroundandCPUutilization(CPUalways
working)
INTERACTIVE:responsetimeandproportionality(simpletaskcompletequickly)

Knowthepropertiesofdifferentalgorithmswediscussed
- Shortest Job First: do u really need me 2 exlpain. nah u dont (answered 4 u)
- FIFO: first in first out.. can suffer from convoy effect (big job in front, itty bitty
jobs behind the big job)
- Round Robin (RR): each thrd is given a quantum q to run, q needs to be large
compared to context switch time.
- MLFQ: ***queue (removed the bad words). a range of queues each with different
priorities associated with them. highest priority queue gets to run its stuff first.
different priorities may have different sizes for their time quanta. here is the set
of rules from the teckstb
k:
- if priority(A) > priority(B). a runs. b sits in the back seat LOL
- if priority(A) = priority(B), A and B run in round robin
- when a job enters the queueueueu, it is placed in the highest priority.

once a job uses up its time allotment at a given level (regardless of


how many times it has given up the see pee you), it has its priority
reduced (ie moves down one queueueuue) LOL
after some time period S, move all jobs in the system to the highest
priority/top-most queue

MemoryManagement
Whyismemorymanagementuseful?
DiskisslowandRAMisfast,somemorymanagementallowsustohavethespeedof
RAMwhilegivingtheillusionofaverylargememorybase.
Whydowehavevirtualmemoryifitissocomplex?
(samereasonasabove,RAMisfast,diskisnot)
WhatarethemechanismsforimplementingtheMMfortheicecreammachine?

Physicalandvirtualaddressing
Virtualaddress:addressforaparticularprocess
Physicaladdress:addressonphysicalmemory
Partitioning,paging,andsegmentation
Partitioning:breakingupphysicalmemoryintochunkstogiveouttoprocesses
Paging:breakingupphysicalmemoryandvirtualmemoryintofixedsizechunks,soany
physicalmemorypagecanbeusedforavirtualmemory
Segmentation:
breakingupvirtualmemoryintosegments(code,heapstack),andusing
base+bounds(base+boundspairforeachsegment)
Pagetables,TLB
WhatarethepoliciesrelatedtoMM?
Pagereplacement
Whataretheoverheadsrelatedtoprovidingmemorymanagement?

VirtualizingMemory

Whatisthedifferencebetweenaphysicalandvirtualaddress?
Virtualaddressisaddressforaprocess(uniqueforthisprocess)
Physicaladdressistheaddressonphysicalmemory
Whatisthedifferencebetweenfixedandvariablepartitioning?
(Whatmore?)
Fixedpartitioning:internalfragmentation
Variable(Dynamic?)partitioning:externalfragmentation
Howdobaseandlimitregisterswork?
Bothareusedifyouwantyourprocesstoberelocatable
Baseregister:keepstrackofthestartingaddressoffsetofyourprocess
Limitregister:keepstrackoftheendaddressoffsetofyourprocess
Alladdressesintheprogramarerelativetotheaddressinthebaseregister
**Whatisinternalfragmentation?
Memoryallocatedtoaprocessbuttheprocessisnotusingallofit

E.g.OSallocates8MBtoaprocess,butprocessonlyuses3MB,theother5MBis
wasted
**Whatisexternalfragmentation?
Deallocatedmemorythatistoosmalltobeusedforotherprocesses
E.g.OSfreesa3MBblock,otherprocessesallrequestsizeslargerthan3MegaBits,
thenthe3MBblockiswasted
Whatisaprotectionfault?

Inpagetableentries,thereisaprotectionbit,thatisprettymuchlikeapermission.Tellsusif
wecanread/write/executeaspecificpage.Aprotectionfault,iswhenwetrytoaccessapagewe
donthaveaccessto(itexists,butwerenotauthorizedtouseit).
Segfaultiswhenyoutrytoaccessinvalidspotsinmemory.Sothatareabetweenthestack
andheapwherenothingisreallyallocatedyeahthatspot.Itsinvalid.SosimplyCANT
accessit.
???
Myguessisyouaccessamemoryaddressyourenotsupposeto(i.e.SEGFAULT)

Paging
Howispagingdifferentfrompartitioning?
Pagesizeisfixed,partitioningcanhavedifferentsizes
(nottoosureaboutthispoint)forpaging,yourealsobreakinguptheprocessesaddress
spaceintochunks,forpartitioning,youretryingtoassignsomephysicaladdressforthe
entireprocessaddressspace
Whataretheadvantages/disadvantagesofpaging?
Advantage:
Internal+externalfragmentationeliminated.
(Whydoesinternalfragmentation
eliminated?Whatifyouhaveapagesize1kbandyouonlyallocate1byte?)
fast
Disadvantage:LargeoverheadIguess,Imeanitjusttakesupalotofspaceingeneralsoyeah.
Whatarepagetables?
Eachprocessgetsitsownpagetable
Keepsamappingofvirtualpagenumber(VPN)topageframenumber(PFN)
(Ithinkthis
explainswhatTLBisShouldntpagetablejustbeatableofvirtualpageswith
indicationsofwhetheritsusedorfree?)
Whatarepagetableentries(PTE)?
Tableswithaddresstranslations
Knowtheseterms
Virtualpagenumber(VPN),pageframenumber(PFN),offset
VPN:
Knowhowtobreakdownvirtualaddressesintopagenumbers,offset
oklol

PageTableEntries
Whatisapagetableentry?
WhatareallofthePTEbitsusedfor?
Dirty(alsoknownasmodify)

Reference
Valid
Protection
Segmentation
Whatissegmentation?
Howdoesitcompare/contrastwithpaging?
Whatareitsadvantages/disadvantageswithrespecttopartitioning,paging?
Whatisasegmenttable?
Howcanpagingandsegmentationbecombined?
PageTables
Pagetablesintroduceoverhead
Spaceforstoringthem
Timetousethemfortranslation
Whattechniquescanbeusedtoreducetheiroverhead?
Howdotwolevel(multilevel)potatotableswork?

TLBs
Thisvideogivesagood,shortdescriptionofwhataTLBdoes,Iwaskindofconfusedandit
helpedmeout.
https://www.youtube.com/watch?v=dQw4w9WgXcQ

:(yudodis
Thanks.Ialsofoundthisvideotobeveryhelpful.Thenarratoralsohasawonderfulaccentthat
drawsyouin.
https://www.youtube.com/watch?v=GzgavGowD_A
LOL
^Thatwasreallyhelpful.Thanks.IusedtoknowonlythebasicsofTLBs,nowafterwatching
thisIamBLTpro
^nowIwantaBLT
^wow,imhungry
^suchtragic

a piece of hardware right near by the CPU/(MMU as well?) that acts as a cache for
recently computed mappings of Virtual Page Number -> Physical Page/Frame Number.
rly useful cuz you can have a page in the TLB that is NOT in physical memory at the
moment (called a
minor fault
)
i thought this was a major fault

WhatproblemdoestheTLBsolve?
HowdoTLBswork?
WhyareTLBseffective?
HowareTLBsmanaged?
WhathappensonaTLBmissfault?
WhatisthedifferencebetweenahardwareandsoftwaremanagedTLB?
PageFaults
Whatisapagefault?

Howisitusedtoimplementdemandpagedvirtualmemory?
Whatisthecompletesequenceofsteps,fromaTLBmisstopaginginfromdisk,for
translatingavirtualaddresstoaphysicaladdress?

**Howmanypotatoesdoesittaketomake1FrenchFry?
3potatoes<rememberthis,veryimportantquestion

Whatisdoneinhardware,whatisdoneinsoftware,whatisdoneinthefryer?

AdvancedMemoryManagement

Whatissharedmemory?
Whatiscopyonwrite?
Whenparentforkschild,dontcopydataimmediately,copydataoverwhenchildwants
towrite.
Whatarememorymappedpotatoes?

PageReplacement
Whatisthepurposeofthepagereplacementalgorithm?
Whatapplicationbehaviordoespagereplacementtrytoexploit?Andhowdoespotatoseed
productionhelptheperformanceoftheLRUpagereplacementalgorithm?
Whenisthepagereplacementalgorithmused?
Understand
Mladys(optimal),FIFO,LRU,LRUClock(secondchance)
Beladys:replacethepagethatwillbeusedtheclosesttoneverinthefuture
FIFO:firstin,firstout.whicheverpageisinthebottom/lastslotofphysicalmemorygets
kickedout
LRU:alwaysplacethemostrecentlypageatthetop/firstslotofphysicalmemory.this
way,theonethatis
Le
ast
R
ecently
Us
edwillbeatthebottom.
CLOCK:approximationofLRU,pickonethatscloseenough
keepacircularqueue&ahandpointer
newpage=>refbit=1
replacement=>checkthepagethatthehandispointingto
ifrefbit=0,evict
else,setrefbit=0,movethehandpointertothenextpage&repeat
Whatisthrashing?
Thrashing
occurswhenacomputer'svirtualmemorysubsystemisinaconstantstateof
paging,rapidlyexchangingdatainmemoryfordataondisk,totheexclusionofmost
applicationlevelprocessing.Thiscausestheperformanceofthecomputertodegradeor
collapse.(Wikipedia:))
Disk
Understandthememoryhierarchyconcept,locality


temporallocality:itemsarelikelyfrequentlyaccessedinthesametimeperiod(e.g.a
counterinaloop)
spatiallocality:itemsthatarephysicallyclosetoeachotherarelikelytobereferenced
withinthesametimeperiod(e.g.arrayelements)
Physicaldiskstructure
Platters,surfaces,tracks,sectors,cylinders,arms,heads
Diskinterface
HowdoestheOSmakerequeststothedisk?
Diskperformance
Whatstepsdeterminediskrequestperformance?
Whatareseek,rotation,transfer?
Seek:movingthediskarmtotherightcylinder
Rotation:waitingforsectortorotateunderthehead
Transfer:transferringdatafrom(orto)thedisksurfaceto(orfrom)thecomputer

Potatoes(FS
)
Files
Directories
Eggs
Sharing:
t
wokeyissues
1) Semanticsofconcurrentaccess(twoprocesseswritesonefile/onereadswhileone
writes)
2) Protection

Protection
Layouts
BufferCache
Whatisafilesystem?
Whyarefilesystemsuseful(whydowehavethem)?


FilesandDirectories
Whatisafile?
sequenceofbytes.
Whatoperationsaresupported?
files:creation,writing,reading,fileremoval,truncationandappending
Directories:Search,Createfile,Deletefile,listdirectory,updatedirectory

Whatcharacteristicsdotheyhave?
Whatarefileaccessmethods?
Whatisadirectory?
??alsoasequenceofbytes??
Whataretheyusedfor?
Directoriesprovidelogicalstructuretofilesystems
Forusers,theyprovideameanstoorganizefiles
Forthefilesystem,theyprovideaconvenientnaminginterface
Allowstheimplementationtoseparatelogicalfileorganizationfromphysicalfile
placement
Storesinformationaboutfiles(owner,permission,etc.)

Howaretheimplemented?
Whatisadirectoryentry?
Howaredirectoriesusedtodopathnametranslation?

FileSystemLayouts
Whatarefilesystemlayoutsusedfor?
Whatarethegeneralstrategies?
Contiguous,linked,indexed?
contiguous:storeeachfileasacontiguousrunofdiskblocks
simple,fast,allowsindexing
weaktoexternalfragmentation
linked:eachblockforafilepointstothenextone(e.g.FAT)
onlygoodforsequentialfileaccessnotgoodformuchelse
indexedstructure:eachfilestructhaspointerstoblocksinanindexblock
goodforsequentialandrandomaccessmethod
requiredmultiple,linkedindexblocks
Whatarethetradeoffsforthosestrategies?
Howdothosestrategiesreflectfileaccessmethods?
Whatisaninode?
Howareinodesdifferentfromdirectories?
Howareinodesanddirectoriesusedtodopathresolution,findfiles?

FileBufferCache
Whatisthefilebuffercache,andwhydooperatingsystemsuseone?
Whatisthedifferencebetweencachingreadsandcachingwrites?

Whatarethetradeoffsofusingmemoryforafilebuffercachevs.VM?

Advanced(FS)PotatoTopics
WhatisFFS,andhowisitanimprovementovertheoriginalUnixfilesystem?
FFS:fastfilesystem
LinuxPotatoevolution:ext2/3/4borrowedheavilyfromFFS
Whatadvantagedologgingfilesystemshave?
HowdoesNTFS(NewTechnologyPotatofromMicrosoft)comparetoFFS?

features
performance

Security
WhatarethebasicthreatstosecurityfromanOSperspective?
1) Interceptionoreavesdroppinglossofconfidentiality
2) modificationattackersaltersexistingfiles,programs..etc
3) theftofservice(availability)attackersinstalldaemon
4) Fabrication(authenticity)attackerscreatescounterfeitobjectswhichappearstocome
fromatrustedsource
WhatmechanismsintheOSprotectusersanddata?
disconnectfrominternet.justkidding.
Eachprocesshasitsownaddressspace,protectedbyhardware.
=A=ShoulditbeENCRYPTION?
Howdoesabufferoverflowattackwork?
overflowsomestackallocatedinputbufferpastthespaceallocatedfortheinput
overwritethereturnaddresswiththeaddressofexploitcode
overwritenextspaceinstackwiththeexploitcodeitself