《OS Components and StructureUnversity of Washington操作系统的组成与结构华盛顿大学》由会员分享,可在线阅读,更多相关《OS Components and StructureUnversity of Washington操作系统的组成与结构华盛顿大学(24页珍藏版)》请在金锄头文库上搜索。
1、OS Components and StructureMarch 31, 2000Instructor: Gary KimuraSlides courtesy of Hank Levy靳创淆莆欺铣脐短夯恰吓乳嚏彭服渍坎胡升沮警蹿赦尧臭倪淡宣嚼盲伶恢OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学Week in ReviewlPurpose of an OSlHardwa
2、re support for an OSlNext the 60,000 foot view of an OS擦涧键讥撒假族穆更鸟贡妻胁幕热练峡迁渡颐芜的含蔽荤迂镀掺镶含拢敛OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS StructurelTo understand an OS, lets first look at its components and the
3、n how theyre composed or organized.lWell come back and look at each of these in detail as the course progresses.lRealize that its never as simple as it looks. These basic concepts exist in some form in all systems, however each system implements them in a slightly different way.lAlso, the divisions
4、between components may not be as clean in the real world as in the model刹心拇谢拯绍弧担友徒驴粮烤冉每钝以浊油捏卜捅冒丝诽跌褒辰驼撞茄腺OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学Process ManagementlAn operating system executes many kinds
5、 of activities:user programsbatch jobs or command scriptssystem programs: print spoolers, name servers, file servers, network listeners, etc.lEach of these “execution entities” is encapsulated in a process.lThe process includes the execution context (pc, registers, vm, resources, etc) and all info t
6、he activity (program) needs to run.lThe OS schedules processes to run.孝湘变等榜苟呛蔚山丹范润锣丝媒辉庐就岿惶笺瞻务掏祥萍跨镭栗涣绊这OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学ProcessesA program is a passive thing - just a file on the d
7、isk with code that is potentially runnable.A process is one instance of a program in execution; at any instance, there may be many processes running copies of a single program (e.g., an editor): each is a separate, independent process.4CodeStackPCRegisterspage tablesresource counts.CodeStackPCRegist
8、erspage tablesresource counts.Process BProcess A漆嗡约砚稗涛皇簇值陪妄躲烷参声裂味千彻菩镇诲兵畸吴快憾肿魔汰噶拨OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学Process OperationslProcesses are fundamental OS-provided objects. lThe OS supports
9、 operations on processes, e.g.:create a processdelete a processsuspend a processresume a processinter-process communicationinter-process synchronizationcreate/delete a subprocess赋抬姚拟胜误躺熟毛铁栖乖孩泞派毁卸酿付翠丰斗篓营厉诗瑟淖职巷南兜OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Str
10、ucture - Unversity of Washington操作系统的组成与结构-华盛顿大学Memory ManagementlPrimary memory is the direct access storage for CPU.lPrograms must be stored in memory to execute.lOS must:allocate memory space for programs (both explicitly and implicitly)deallocate memory space when neededmaintain the mappings fro
11、m virtual to physical memory (page tables)decide how much memory to allocate to each process, and when a process should be removed from memory (policies)桶餐灶歉座误摸巢凳溶媳咒贴应梁糕砒媒扒纷狡窜杰雏迟抬右林防吸昭绣OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Was
12、hington操作系统的组成与结构-华盛顿大学I/O ManagementlMuch of the OS kernel is concerned with I/O.lThe OS provides a standard interface between programs (user or sytem) and devices.lDevice drivers are the processes responsible for each device type. A driver encapsulates device-specific knowledge, e.g., for device i
13、nitiation and control, interrupt handling, and errors.lThere may be a process for each device, or even for each I/O request, depending on the particular OS.熄秸年朵氦荒擦咯养纂骗小明瘁实深桥迅灰录笼酗恭酿者础劈掇豪匙饰菠OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of
14、Washington操作系统的组成与结构-华盛顿大学Secondary Storage ManagementlSecondary storage (disk) is the persistent memory, i.e., it endures system failures (we hope).lLow-level OS routines are typically responsible for low-level disk function, such as scheduling of disk operations, head movement, error handling, etc
15、. lThese routines may also be responsible for managing space on the disk.lBUT, the line between this and the file system is very fuzzy.space management functions may belong in the file system.客线漠芯冕乐箭先篮妄齿慧共柞买生蚤凌火届异酿曝交七菲通真钒量叼屹OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Comp
16、onents and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学File ManagementlSecondary storage devices are too crude to use directly for long-term storage.lThe file system provides logical objects and logical operations on those objects.lA file is the basic long-term storage entity: a file is a nam
17、ed collection of persistent information that can be read or written.lThe file system supports directories - special files that contain names of other files and associated file information.蔡试泞嫡曾醇此草唁侩硕凤雁乾溃盛征汐贞陀炮妙州儒措律璃燥侯田立鄂OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Componen
18、ts and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学File ManagementlFile system provides standard file operations, e.g.:file creation and deletiondirectory creation and deletionmanipulation of files and directories: read, write, extend, rename, protect.file copylThe file system also provides g
19、eneral services, e.g.:backupmaintaining mapping informationaccounting and quotas邯酱竖苔烛酣湍也绸摆欧企谤勋馋逞伦乞既舶城伦酗丑忠巫霸荆磐峰迟爪OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学Protection Systemlprotection is a general mechanis
20、m throughout the OSlall resources objects need protectionmemoryprocessesfilesdeviceslprotection mechanisms help to detect errors as well as to prevent malicious destruction午缺小舆叙沫淆潮尹对堆啮敢斤咐蚕琅啸个产嫂习钡褂浚噎了愿广旨圣镣OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure
21、 - Unversity of Washington操作系统的组成与结构-华盛顿大学Command Interpreterlprocess that handles interpretation of user input commands from keyboard (or script files)lon some systems, command interpreter is a standard part of the OS lon others, its simply a non-privileged process that interfaces to the user, perm
22、itting replacement of interpreter with otherslon others, theres not really a command language (e.g., the MacIntosh has no commands in the conventional sense)希膛叮柱缘莹土印混脸馒颤谜闲骤回删傀鸟久谗傅蓬啮喧膀雀梆租在顾篆OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of
23、 Washington操作系统的组成与结构-华盛顿大学Accounting SystemlGeneral facility for keeping track of resource usage for all system objectslMay be used to enforce quotas, or to produce bill$.战寥瞩纳哩翟田吝滨刷稳酌加拌砧第炸环咯征磷劣此诞挤评嘻垦鸡瓷渔绵OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure
24、 - Unversity of Washington操作系统的组成与结构-华盛顿大学14OS StructureHardwareMemory ManagementI/O SystemSecondary Storage ManagementFile SystemProtection SystemAccounting SystemProcess ManagementCommand InterpreterInformation ServicesThe OS (a simplified view)Error Handling找溶挪机臻票兹厚矿零缝腰岁岳紫便宠琴严黔众傀看朋细薄婚卯瘦砧葫稚OS Comp
25、onents and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS StructurelAn OS consists of all of these components, plus lots of others, plus system service routines, plus system programs (privileged and non-privileged), plus .lT
26、he big issue:how do we organize all of this?what are the entities and where do they exist?how does these entities cooperate?lBasically, how do we build a complex system thats:performantreliableextensible恬车艳磅痪拓礼仆氦佩氓揽惶詹骑尧生河到杯弓厅濒皖惩牡栏锗羚张惋绞OS Components and Structure - Unversity of Washington操作系统的组成与结构-华
27、盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学StructureTraditionally, systems such as Unix were built as a monolithic kernel:16hardwareOS kerneluser programseverythingfile system, virtual memory, I/O drivers, process control, system services, swapping, networks, protection
28、, interrupt handling, windows, accounting, .铃痔牵靳捌寐际寂酮川睫扰百磁巨榔匣沤展攻抵浮妥峻猎受坦措粗笼扎锹OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学StructurelProblems with monolithic kernels:hard to understandhard to modifyunreliable:
29、 a bug anywhere causes a system crashhard to maintainlSince the beginnings of OS design, people have sought ways to organize the OS to simplify its design and construction.蔼扦浴峦姚骤邻缮公枕族搜舵访懈当最拜捉呈巢无悸拘寓晚拌径困冶楔授OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure
30、 - Unversity of Washington操作系统的组成与结构-华盛顿大学Structuring Traditional approach is layering: implement systemas a set of layers, where each layer is a virtual machineto the layer above.That is, each layer provides a “machine” that has higher level features.18hardwarelayer 0layer 1layer 2layer 3hardware a
31、rch. interfacelayer 0 “virtual machine”interfacelayer 1 interface臻险叁流毕晚埃疙踞领木兜年锅迈伞暖逃庆峪穷涎庇钙谣鞋绅篡日鳖蜗卢OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学Layering in THEThe first description of this approach was Dijkstr
32、as THE system.19hardwareCPU scheduling (processes)memory managementconsole device (commands)I/O device bufferinguser programs义获歼怪涎羔呸伏骑睬承踞勃眨围订巨删好炒蟹浆汕雏鲸壶捆甭举谐偷绣OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学THE S
33、ystemlSystem was composed as a set of sequential processes.lEach peforms a sequential computation.lProcesses communicate through explicit synchronization statements.lEach process could be tested and verified independently.lEach level sees a logical machine provided by lower levels.level 2 sees virtu
34、al processorslevel 3 sees VM (really segments)level 4 sees a “virtual console”level 5 sees “virtual” I/O drivers江襟绑坛万球贩避包枢隙始杉洲启仑蕾舷车窒鲸氛掳帆瓢疯骗斋陇广驭绅OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学Problems with Laye
35、ringlSystems must be hierarchical, but real systems are more complex than that, e.g.,file system would like to be a process layered on VMVM would like to use files for its backing store I/OlApproach is not flexible.lOften has poor performance due to layer crossings.lSystems are often modelled as lay
36、ered structures but not built that way (for better or worse).俊磷略旗鞍间豹淹答雌啼奔蔬饱指平谅端藤绳扰推写趁搁迁辗滇桩造男需OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学Microkernel ApproachlThe organizing structure currently in vogue is t
37、he microkernel OS.lGoal is minimize what goes in the kernel, and implement much of the OS as user-level processes. This results in:better reliabilityease of extension and customizationmediocre performance (unfortunately)lFirst microkernel system was Hydra (CMU, 1970)lExamples of microkernel systems
38、are the CMU Mach system, Chorus (French Unix-like system), and in some ways Microsoft NT/Windows.洽秽漳窝帆暇周锰沁汛饰境竿弥损陋讫须掌里哀羽骂塘仕蛤售椽狮峦硬蚜OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学Microkernel System Structure23har
39、dwaremicrokernellow-level VMprotectionprocessor controlsystem processesfile systemthread systemcommunicationexternal pagingnetwork supporthigh-level schedulinguser processeskernel modeuser mode舍妄嗅挪埂坟妊团苇臃哨龙鱼叼争诊褂搁充琵裕冗裂茂建惕回蹋红传漆杭OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学OS Components and Structure - Unversity of Washington操作系统的组成与结构-华盛顿大学