operating systems: lesson 1: introduction to ... -...
Post on 18-Oct-2019
21 Views
Preview:
TRANSCRIPT
OperatingSystems
OPERATING SYSTEMS:
Lesson 1:Introduction to Operating Systems
1
Jesús Carretero PérezDavid Expósito Singh José Daniel García SánchezFrancisco Javier García BlasFlorin Isaila
OperatingSystems
WhystudyOperatingSystems?
a) OS,anditsinternals,largelyinfluencesgeneralfunctioning,includingsecurityandperformance.
b) ImportanceofOSchoiceinanorganizationishigherandhigher.Trendtostrategicdecision.
c) Knowledgefundamentaltodevelopapplicationsifgoodperformanceisdesiredandtounderstandcausesofmanyproblems.
2
OperatingSystems
UnderstandingOS
• WhichOStakesbetteradvantageofagivensystemcapabilities?
• DoestheOSsupportallthedevicesIintendtoconnecttothecomputer?Ifnot,whatcanIdo?
• Isitsecureenoughfortheenvironmentitwillbeintegratedin?
• Willmyapplicationsrun«smoothly»onthechosenOS?Howwillmyconcreteworkloadadapttotheplatform?
3
OperatingSystems
Tomaketherightchoice
• IsiteasytofindadminsforthisOS?Isadministrationanobscure taskneedingultra-specializedpersonnel?
• WhatsupportdoestheOShave?Whichistheupdatepublishingrate?
• Besidescost,whatfutureexpectationsdoesithave?
4
Protect your investment
OperatingSystems
Todevelopsoftwarewithgoodperformance
5
• SoftwareneedsOSservicesformaytasks.– WhatservicesdoestheOSofferandhowdoIinvokethem?
• Totakeadvantageofnewarchitecturesmultithreadingisessential.– HowdoIdevelopamultithreadedapplicationformyOS?
OperatingSystems
Anengineermustbe
6
OPERATING SYSTEMAGNOSTIC
OperatingSystems
FourComponentsofaComputerSystem
7
OperatingSystems
ComputerSystemStructure
• Computersystemcanbedividedintofourcomponents– Hardware– providesbasiccomputingresources
• CPU,memory,I/Odevices– Operatingsystem
• Controlsandcoordinatesuseofhardwareamongvariousapplicationsandusers
– Applicationprograms– definethewaysinwhichthesystemresourcesareusedtosolvethecomputingproblemsoftheusers• Wordprocessors,compilers,webbrowsers,databasesystems,videogames
– Users• People,machines,othercomputers
8
OperatingSystems
ComputerSystemOrganization
• Computer-systemoperation– OneormoreCPUs,devicecontrollersconnectthroughcommonbus
providingaccesstosharedmemory– ConcurrentexecutionofCPUsanddevicescompetingformemory
cycles
9
OperatingSystems
HowaModernComputerWorks
10
OperatingSystems
Computer-SystemOperation
• I/OdevicesandtheCPUcanexecuteconcurrently• Eachdevicecontrollerisinchargeofaparticulardevicetype
• Eachdevicecontrollerhasalocalbuffer• CPUmovesdatafrom/tomainmemoryto/fromlocalbuffers
• I/Oisfromthedevicetolocalbufferofcontroller• DevicecontrollerinformsCPUthatithasfinisheditsoperationbycausinganinterrupt
11
OperatingSystems
InterruptTimeline
12
OperatingSystems
CommonFunctionsofInterrupts
• Interrupttransferscontroltotheinterruptserviceroutinegenerally,throughtheinterrupt vector,whichcontainstheaddressesofalltheserviceroutines
• Interruptarchitecturemustsavetheaddressoftheinterruptedinstruction
• Incominginterruptsaredisabled whileanotherinterruptisbeingprocessedtopreventalostinterrupt
• Atrap isasoftware-generatedinterruptcausedeitherbyanerrororauserrequest
• Anoperatingsystemisinterruptdriven
13
OperatingSystems
InterruptHandling
• TheoperatingsystempreservestheCPUstatebystoringregistersandtheprogramcounter
• Determineswhichtypeofinterrupthasoccurred.• Separatesegmentsofcodedeterminewhatactionshouldbetakenforeachtypeofinterrupt
14
OperatingSystems
I/OStructure
• AfterI/Ostarts,controlreturnstouserprogramonlyuponI/Ocompletion– AtmostoneI/Orequestisoutstandingatatime,nosimultaneousI/Oprocessing
• Systemcall– requesttotheoperatingsystemtoallowusertowaitforI/Ocompletion
• Device-statustablecontainsentryforeachI/Odeviceindicatingitstype,address,andstate
• OperatingsystemindexesintoI/Odevicetabletodeterminedevicestatusandtomodifytableentrytoincludeinterrupt
15
OperatingSystems
DirectMemoryAccessStructure
• Usedforhigh-speedI/Odevicesabletotransmitinformationatclosetomemoryspeeds
• DevicecontrollertransfersblocksofdatafrombufferstoragedirectlytomainmemorywithoutCPUintervention
• Onlyoneinterruptisgeneratedperblock,ratherthantheoneinterruptperbyte
16
OperatingSystems
Storage-DeviceHierarchy
17
OperatingSystems
PerformanceofVariousLevelsofStorage
• Movementbetweenlevelsofstoragehierarchycanbeexplicitorimplicit
18
OperatingSystems
MigrationofIntegerAfromDisktoRegister
• Multitaskingenvironmentsmustbecarefultousemostrecentvalue,nomatterwhereitisstoredinthestoragehierarchy
• MultiprocessorenvironmentmustprovidecachecoherencyinhardwaresuchthatallCPUshavethemostrecentvalueintheircache
19
OperatingSystems
StorageStructure
• Mainmemory– onlylargestoragemediathattheCPUcanaccessdirectly
• Secondarystorage– extensionofmainmemorythatprovideslargenonvolatilestoragecapacity
• Magneticdisks– rigidmetalorglassplatterscoveredwithmagneticrecordingmaterial– Disksurfaceislogicallydividedintotracks,whicharesubdividedintosectors
– Thediskcontrollerdeterminesthelogicalinteractionbetweenthedeviceandthecomputer
20
OperatingSystems
StorageHierarchy
• Storagesystemsorganizedinhierarchy– Speed– Cost– Volatility
• Caching – copyinginformationintofasterstoragesystem;mainmemorycanbeviewedasalastcacheforsecondarystorage
21
OperatingSystems
Caching
• Importantprinciple,performedatmanylevelsinacomputer(inhardware,operatingsystem,software)
• Informationinusecopiedfromslowertofasterstoragetemporarily
• Fasterstorage(cache)checkedfirsttodetermineifinformationisthere– Ifitis,informationuseddirectlyfromthecache(fast)– Ifnot,datacopiedtocacheandusedthere
• Cachesmallerthanstoragebeingcached– Cachemanagementimportantdesignproblem– Cachesizeandreplacementpolicy
22
OperatingSystems
WhatisanOperatingSystem?
• Aprogramthatactsasanintermediarybetweenauserofacomputerandthecomputerhardware
• Operatingsystemgoals:– Executeuserprogramsandmakesolvinguserproblemseasier
– Makethecomputersystemconvenienttouse– Usethecomputerhardwareinanefficientmanner
23
OperatingSystems
OperatingSystemDefinition
• OSisaresourceallocator– Managesallresources– Decidesbetweenconflictingrequestsforefficientandfairresourceuse
• OSisacontrolprogram– Controlsexecutionofprogramstopreventerrorsandimproperuseofthecomputer
24
OperatingSystems
OperatingSystemDefinition(Cont)
• Nouniversallyaccepteddefinition• “Everythingavendorshipswhenyouorderanoperatingsystem” isgoodapproximation– Butvarieswildly
• “Theoneprogramrunningatalltimesonthecomputer” isthekernel.Everythingelseiseitherasystemprogram(shipswiththeoperatingsystem)oranapplicationprogram
25
OperatingSystems
OperatingSystemStructure
• Multiprogramming neededforefficiency– SingleprogramcannotkeepCPUandI/Odevicesbusyatalltimes– Multiprogramming organizes jobs(codeanddata)soCPUalwayshasoneto
execute– Asubsetoftotaljobs insystemiskeptinmemory– Onejobselectedandrunviajobscheduling– Whenithastowait(for I/Oforexample),OSswitchestoanother job
• Timesharing(multitasking)islogicalextensioninwhichCPUswitchesjobssofrequently thatuserscaninteractwitheachjobwhileitisrunning, creatinginteractive computing– Responsetime shouldbe<1second– Eachuserhasatleastoneprogramexecutinginmemory[process– Ifseveraljobs readytorunatthesametime[ CPUscheduling– Ifprocessesdon’t fitinmemory,swappingmovestheminandouttorun– Virtualmemoryallowsexecutionofprocessesnotcompletely inmemory
26
OperatingSystems
Responsetime
27
OperatingSystems
MemoryLayoutforMultiprogrammedSystem
28
OperatingSystems
Operating-SystemOperations
• Interruptdrivenbyhardware• Softwareerrororrequestcreatesexceptionortrap
– Divisionbyzero,requestforoperatingsystemservice• Otherprocessproblemsincludeinfiniteloop,processes
modifyingeachotherortheoperatingsystem• Dual-modeoperationallowsOStoprotectitselfand
othersystemcomponents– Usermodeandkernelmode– Modebitprovidedbyhardware
• Providesabilitytodistinguishwhensystemisrunningusercodeorkernelcode
• Someinstructionsdesignatedasprivileged,onlyexecutable inkernelmode
• Systemcallchangesmodetokernel,returnfromcallresets ittouser
29
OperatingSystems
TransitionfromUsertoKernelMode
30
OperatingSystems
Process Management
• Aprocessisaprograminexecution.Itisaunitofworkwithinthesystem.Programisapassiveentity,processisanactiveentity.
• Processneedsresourcestoaccomplishitstask– CPU,memory,I/O,files– Initializationdata
• Processterminationrequiresreclaimofanyreusableresources• Single-threadedprocesshasoneprogramcounterspecifyinglocationof
nextinstructiontoexecute– Processexecutesinstructionssequentially,oneatatime,until
completion• Multi-threadedprocesshasoneprogramcounterperthread• Typicallyasystemhasmanyprocesses,someusers,someoperating
systemrunningconcurrentlyononeormoreCPUs– ConcurrencybymultiplexingtheCPUsamongtheprocesses/threads
31
OperatingSystems
ProcessManagementActivities
Theoperatingsystemisresponsibleforthefollowingactivitiesinconnectionwithprocessmanagement:
• Creatinganddeletingbothuserandsystemprocesses
• Suspendingandresumingprocesses• Providingmechanismsforprocesssynchronization• Providingmechanismsforprocesscommunication• Providingmechanismsfordeadlockhandling
32
OperatingSystems
MemoryManagement
• Alldatainmemorybeforeandafterprocessing• Allinstructionsinmemoryinordertoexecute• Memorymanagementactivities
– Keepingtrackofwhichpartsofmemoryarecurrentlybeingusedandbywhom
– Decidingwhichprocesses(orpartsthereof)anddatatomoveintoandoutofmemory
– Allocatinganddeallocatingmemoryspaceasneeded
33
OperatingSystems
StorageManagement
• OSprovidesuniform,logicalviewofinformationstorage– Abstractsphysicalpropertiestologicalstorageunit- file– Eachmediumiscontrolledbydevice(i.e.,diskdrive,tape
drive)• Varyingpropertiesincludeaccessspeed,capacity,data-transferrate,accessmethod(sequentialorrandom)
• File-Systemmanagement– Filesusuallyorganizedintodirectories– Accesscontrolonmostsystemstodeterminewhocan
accesswhat– OSactivitiesinclude
• Creatinganddeletingfilesanddirectories• Primitivestomanipulatefilesanddirs• Mappingfilesontosecondarystorage• Backupfilesontostable(non-volatile)storagemedia
34
OperatingSystems
Mass-StorageManagement
• Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time
• Proper management is of central importance• Entire speed of computer operation hinges on disk subsystem and
its algorithms• OS activities
– Free-space management– Storage allocation– Disk scheduling
• Some storage need not be fast– Tertiary storage includes optical storage, magnetic tape– Still must be managed– Varies between WORM (write-once, read-many-times) and RW
(read-write)
35
OperatingSystems
I/OSubsystem
• OnepurposeofOSistohidepeculiaritiesofhardwaredevicesfromtheuser
• I/Osubsystemresponsiblefor– MemorymanagementofI/Oincludingbuffering(storingdatatemporarilywhileitisbeingtransferred),caching(storingpartsofdatainfasterstorageforperformance),spooling(theoverlappingofoutputofonejobwithinputofotherjobs)
– Generaldevice-driverinterface– Driversforspecifichardwaredevices
36
OperatingSystems
ProtectionandSecurity
• Protection– anymechanismforcontrollingaccessofprocessesoruserstoresourcesdefinedbytheOS
• Security– defenseofthesystemagainstinternalandexternalattacks– Hugerange,includingdenial-of-service,worms,viruses,identity
theft,theftofservice• Systemsgenerallyfirstdistinguishamongusers,todeterminewho
candowhat– Useridentities(userIDs,securityIDs)includenameandassociated
number,oneperuser– UserIDthenassociatedwithallfiles,processesofthatuserto
determineaccesscontrol– Groupidentifier(groupID)allowssetofuserstobedefinedand
controlsmanaged,thenalsoassociatedwitheachprocess,file– PrivilegeescalationallowsusertochangetoeffectiveIDwithmore
rights
37
OperatingSystems
Conceptualstructure
• Executionmodes:– Usermode:Executesuserprocesses.– Kernelmode:ExecutestheOSkernel.
• ProcessesandOSuseseparatememoryspaces.
• WhenaprocessneedsaservicerequestsittotheOSthroughasystemcall.– TheOperatingSystementersexecutiontoperformrequestedfunction.
38
OperatingSystems
Structure
OperatingSystems
Monolitics
Structured
Layered
Client/Server
Modular
39
OperatingSystems
MonoliticOS
• Noclearorwelldefinedstructure.• AlltheOScodelinkedintoasingleexecutablerunningin
kernelmode.– Singleaddressspace.– Nodatahidingamongmodules.
• Moreefficientatthecostofverycomplexdevelopmentandmaintenance.
• Examples:– AllOSuntil’80,includingUNIX.– MS-DOSandcurrentUNIXvariants:Solaris,Linux,AIX,HP-UX,...
40
OperatingSystems
LayeredOS
• Organizationasasetoflayerswithclearandwelldefinedinterfaces.• Eachlayerontopoflowerlayer.• Advantates:
– Modularity.– Datahiding.– Betterdevelopmentanddebugging.
• Lessefficientduetoneedtocrossmanylayerstoperformanoperation.• DifficulttodistributeOSfunctionsintolayers.• Examples:
– MacOS Xkernel– OS/2
41
OperatingSystems
Client/Serverapproach
¨ Mostservicesasuserprocesseswithasmallamountoffunctioality intoamicrokernel.
¨ Advantages:¨ Veryflexible. Eachservercanbedevelopedanddebuggedinisolation.¨ Easilyextensible toadistributedmodel
¨ Drawbacks:¤ Overheadinservicesexecution.
¨ Examples:¤ MinixyAmoeba(Tanenbaum)¤ MacOSandWindowsNT.
¤ Howeverservicesexecuted inkernelspaceforperformancereasons.
42
OperatingSystems
Modular
• Most modern operating systems implement kernel moduleso Uses object-oriented approacho Each core component is separateo Each talks to the others over known interfaceso Each is loadable as needed within the kernel
• Overall, similar to layers but with more flexible
43
OperatingSystems
Classifications
¨Numberofprocesses:¤Single-Task.¤Multitaks.
¨InteractionMode:¤Interactive.¤Batch.
¨Numberofusers:¤Monouser.¤Multiuser.
¨Numberofprocessors:¤Monoprocessor.¤Multiprocessor.
¨Threading:¤Monothread.¤Multithread.
¨uses:¤Client.¤Server.¤Embedded.¤Real-Time.
44
OperatingSystems
OSstartup
• OSstartsupwhecomputerisswitchedon.– Initiallyinsecondarystorage.– Howdoesitcometomainmemory?– Howdesitstartexecutionafterbeingloaded?
45
OperatingSystems
Phases
ROMBoot
OS Loader
OS resident
partNormal
execution
46
OperatingSystems
Computer Startup
• bootstrapprogram isloadedatpower-uporreboot– TypicallystoredinROMorEPROM,generallyknownas
firmware– Initializesallaspectsofsystem– Loadsoperatingsystemkernelandstartsexecution
47
OperatingSystems
ROMboot
• RESETsignalloadspredefinedvaluesinregisters.– PC:bootaddressinroomboot.
• StartrunningROMboot:– Systemhardwaretest.– LoadintomemorytoOSloader.
48
OperatingSystems
OSloader
¨Programloaderisindiskbootsector.
¨ResponsibleforloadingtherestoftheOS.
¨Verifiesthemagicwordinbootsector.
49
OperatingSystems
GeneratingtheOS
• OSdesignedforacompleteclassofmachineswithseveralvariantsofconfigurationsandmanysupporteddevices.
• NeedtogenerateOScopybasedoncharacteristicsofspecificmachineconfiguration.
• Generationperformedduringinitialinstallation.
GenericOS
SpecificOSGeneration
50
OperatingSystems
OPERATING SYSTEMS:
Lesson 1:Introduction to Operating Systems
51
Jesús Carretero PérezDavid Expósito Singh José Daniel García SánchezFrancisco Javier García BlasFlorin Isaila
top related