《计算机操作系统--operating-system-overview教案资料.ppt》由会员分享,可在线阅读,更多相关《计算机操作系统--operating-system-overview教案资料.ppt(52页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、OPERATING SYSTEM OVERVIEW计算机操作系统-Operating-System-OverviewOPERATING SYSTEM OVERVIEW1.1 Objectives and Functions(p45)1.1 Objectives and Functions(p45)1.1.1 Overview1.1.1 Overview1.1.2 The Operating System as a User/Computer Interface1.1.2 The Operating System as a User/Computer Interface1.1.3 The Ope
2、rating System as Resource Manager1.1.3 The Operating System as Resource Manager1.1.4 Ease of Evolution of an Operating System1.1.4 Ease of Evolution of an Operating SystemOPERATING SYSTEM OVERVIEWvAn operating system is a An operating system is a programprogram that manages the that manages the comp
3、uter,controls the execution of application computer,controls the execution of application programs and acts as an programs and acts as an interfaceinterface(接口接口接口接口)between)between the user of a computer and the computer hardware.the user of a computer and the computer hardware.vObjectivesObjective
4、sConvenienceConvenience(方便)(方便)(方便)(方便)EfficiencyEfficiency(有效)(有效)(有效)(有效)Ability to evolveAbility to evolve(易扩展)(易扩展)(易扩展)(易扩展)1.1.1 Overview1.1.1 OverviewOPERATING SYSTEM OVERVIEW1.1.2 OS as a User/Computer Interface(I)1.1.2 OS as a User/Computer Interface(I)Figure 2.1 Layers and Views of a Compu
5、ter SystemComputer HardwareOperating SystemUtilities(Compiler,Database)Applications ProgramsOperatingSystem DesignerProgrammersEnd UserOPERATING SYSTEM OVERVIEWvThe operating system The operating system masksmasks(隐藏)(隐藏)(隐藏)(隐藏)the details of the details of the hardware from the programmerthe hardw
6、are from the programmer,and provides and provides the programmer with a convenient interface for the programmer with a convenient interface for using the system.using the system.vThe types of system interfaceThe types of system interfaceCommand interface:system command(internalCommand interface:syst
7、em command(internal、external)external)Graphics interface:windowsGraphics interface:windowsProgrammer interface:system call,c-libProgrammer interface:system call,c-libOS as a User/Computer Interface(II)OS as a User/Computer Interface(II)OPERATING SYSTEM OVERVIEWServices of the Operating System(I)Serv
8、ices of the Operating System(I)vProgram creationProgram creationSuch as:fork(unix)Such as:fork(unix)、CreateProcess(win)CreateProcess(win)vProgram executionProgram executionSuch as:execl,execpSuch as:execl,execpvAccess to I/O devicesAccess to I/O devicesSuch as:read/writeSuch as:read/writevControlled
9、 access to filesControlled access to filesSuch as:read/writeSuch as:read/writeOPERATING SYSTEM OVERVIEWServices of the Operating System(II)Services of the Operating System(II)vSystem accessSystem accessProvide protection and authorizedProvide protection and authorizedvError detection and responseErr
10、or detection and responseSuch as:errorSuch as:errorvAccountingAccountingOPERATING SYSTEM OVERVIEW1.1.3 OS as Resource Manager(I)1.1.3 OS as Resource Manager(I)(p47p47)vTypes of Resource:CPUTypes of Resource:CPU、MemoryMemory、DevicesDevicesvCPU:chapter 3.4.5.6.9.10CPU:chapter 3.4.5.6.9.10vMemory:chapt
11、er 7.8Memory:chapter 7.8vI/O Devices:chapter 11.12I/O Devices:chapter 11.12OPERATING SYSTEM OVERVIEWOS as Resource Manager(II)OS as Resource Manager(II)vAs a control mechanism is unusual in two respectsAs a control mechanism is unusual in two respectsThe OS functions in the same way as ordinary The
12、OS functions in the same way as ordinary computer software;that is,it is a program computer software;that is,it is a program executed by the processor.executed by the processor.The OS frequently The OS frequently relinquishes controlrelinquishes control(释放控释放控释放控释放控制制制制)and must depend on the proces
13、sor to allow it)and must depend on the processor to allow it to to regain controlregain control(获取控制)(获取控制)(获取控制)(获取控制).OPERATING SYSTEM OVERVIEWOS as Resource Manager(III Figure 2.2)OS as Resource Manager(III Figure 2.2)vManagement of CPUManagement of CPUvManagement of I/O DeviceManagement of I/O D
14、evicevManagement of MemoryManagement of MemoryvManagement of FilesManagement of FilesvConcept:Concept:KernelKernel、NucleusNucleus(内核内核内核内核):Always in main):Always in main memory,contains the most-frequently-used memory,contains the most-frequently-used functionsfunctionsOPERATING SYSTEM OVERVIEW1.1.
15、4 Ease of Evolution1.1.4 Ease of Evolution(p49p49)vReasons for evolutionReasons for evolutionhardware upgradeshardware upgradesExp:support pagingExp:support pagingnew servicesnew servicesfixesfixesvImplementsImplementssoftware engineering:modulessoftware engineering:modules、layerlayer、object designo
16、bject designOPERATING SYSTEM OVERVIEW1.2 The Evolution of Operating Systems1.2 The Evolution of Operating Systems1.2.1 Serial Processing1.2.1 Serial Processing1.2.2 Simple 1.2.2 Simple BatchBatch Systems Systems1.2.3 1.2.3 MultiprogrammedMultiprogrammed(多道)(多道)(多道)(多道)Batch Systems Batch Systems1.2.
17、4 1.2.4 Time-SharingTime-Sharing Systems SystemsOPERATING SYSTEM OVERVIEW1.2.1 Serial Processing(p501.2.1 Serial Processing(p50串行处理串行处理串行处理串行处理)vExampleExampleInput Input Calculate Calculate Print PrintvProblemsProblemsSchedulingScheduling:The estimated time is not accurate:The estimated time is not
18、 accurateSetup timeSetup time:Between the setup procedure,if an:Between the setup procedure,if an error occurred,then must go back to the error occurred,then must go back to the beginning of the setup sequencebeginning of the setup sequenceContradiction between human and machineContradiction between
19、 human and machineOPERATING SYSTEM OVERVIEW1.2.2 Simple Batch System1.2.2 Simple Batch SystemvObjectivesObjectives:Solution contradiction between human Solution contradiction between human and machineand machineUser submits the job on cards or tape to a User submits the job on cards or tape to a com
20、puter operator(use JCLcomputer operator(use JCL(job control job control language)language)vImplement:MonitorImplement:MonitorOPERATING SYSTEM OVERVIEWFrom the Point of View of the Monitor(p51)From the Point of View of the Monitor(p51)vvMonitorMonitor is responsible for the is responsible for the run
21、ning of every jobrunning of every jobvvControls are transferred between Controls are transferred between monitor and other user programsmonitor and other user programsInterrupt processingDevice DriversJob SequencingControl Language InterpreterUser Program AreamonitorMemory layout for a resident(驻留)m
22、onitorOPERATING SYSTEM OVERVIEWFrom the Point of View of the ProcessorvWhen CPU runs command of monitor,the monitor When CPU runs command of monitor,the monitor gains the control.gains the control.vWhen CPU runs command of user program,the When CPU runs command of user program,the user program gains
23、 the control.user program gains the control.vTransfer the control:Transfer the control:First monitor gains the First monitor gains the control,when user program load in,it gains the control,when user program load in,it gains the control,when the user program finish or error,the control,when the user
24、 program finish or error,the monitor regainsmonitor regains(重获)(重获)(重获)(重获)the control.the control.OPERATING SYSTEM OVERVIEWJCL(Job Control Language)JCL(Job Control Language)$JOB /begin$JOB /begin$FTN /using Fortran compile and link$FTN /using Fortran compile and linkFortran /instructionsFortran /in
25、structions$LOAD /load in runable modules$LOAD /load in runable modules$RUN /running.$RUN /running.$END /finish do the job$END /finish do the jobOPERATING SYSTEM OVERVIEWOther Hardware Feature Desirable(p53)Other Hardware Feature Desirable(p53)vvMemory protectionMemory protection(内存保护)(内存保护)(内存保护)(内存
26、保护):User space and system User space and system space are independent.space are independent.E.g.Hardware can detect outside accessing error.E.g.Hardware can detect outside accessing error.vvTimer interruptTimer interrupt(时钟中断)(时钟中断)(时钟中断)(时钟中断):When the timer expires,an When the timer expires,an int
27、errupt occurs.interrupt occurs.vvPrivileged instructionsPrivileged instructions(特权指令)(特权指令)(特权指令)(特权指令):Can be executed only Can be executed only by the monitor.by the monitor.vvInterrupts:Interrupts:Improvement efficiencyImprovement efficiency Easy for relinquishingEasy for relinquishing(释放)(释放)(释放
28、)(释放)and regaining control and regaining controlOPERATING SYSTEM OVERVIEW1.2.3 Multiprogrammed Batch Systems1.2.3 Multiprogrammed Batch SystemsRead one record0.0015 secondsExecute 100 instructions0.0001 secondsWrite one record0.0015 secondsTOTAL0.0031 secondsPercent CPU Utilization=0.0001/0.0031=3.2
29、%Figure 2.4 System Utilization ExamplevvUniprogrammingUniprogramming(单道)(单道)(单道)(单道)has low efficiency has low efficiency(效率)(效率)(效率)(效率):CPU-I/O contradictionCPU-I/O contradictionOPERATING SYSTEM OVERVIEWMultiprogramming/MultitaskingMultiprogramming/MultitaskingvThere are many user programs in the
30、There are many user programs in the memory.memory.vHardware need for Multiprogramming.Hardware need for Multiprogramming.InterruptionInterruptionvFor example:p55 Fig2.5For example:p55 Fig2.5OPERATING SYSTEM OVERVIEWExample of MultiprogrammingExample of Multiprogrammingv256k available memoryvvNotes:n
31、ot consider the resource competitionNotes:not consider the resource competitionJOB1JOB2JOB3Type of JOBHeavy ComputerHeavy I/OHeavy I/ODuration5min15min10minMemory required50k100k80kNeed diskNoNoYesNeed terminalNoYesNoNeed printerNoNoYesTable 2.1 Sample Program Execution Attributes OPERATING SYSTEM O
32、VERVIEWAnalysisAnalysisOPERATING SYSTEM OVERVIEWAnalysisAnalysisvSingleProcessor use5/(5+15+10)=17%Memory use=(50*5+100*15+80*10)/256/30=33%Disk use=10/30=33%Printer use10/30=33%Total time 5+15+1030Throughput 6 job/hourMean response time(5+20+30)/3=18OPERATING SYSTEM OVERVIEWAnalysisAnalysisvvMultip
33、rogrammingMultiprogrammingProcessor use5/15=33%Memory use=(50+100+80)*5+(100+80)*5+100*5/256/15=65%Disk use=10/15=67%Printer use10/15=67%Total time15Throughout 12job/hourMean response time(5+10+15)/3=10OPERATING SYSTEM OVERVIEWSophisticated(Sophisticated(复杂性复杂性复杂性复杂性)of Multiprogramming(p57)of Multi
34、programming(p57)vMemory managementMemory managementvScheduling Scheduling AlgorithmAlgorithm(算法)(算法)(算法)(算法):The processor:The processor(处理器)(处理器)(处理器)(处理器)must decide which one to run.must decide which one to run.OPERATING SYSTEM OVERVIEW1.2.4 T1.2.4 Time-Sharing Systemsime-Sharing SystemsvvMultipl
35、e users simultaneouslyMultiple users simultaneously(同时)(同时)(同时)(同时)access the system access the system through terminals(through terminals(终端终端终端终端)vvConcepts:Concepts:time slicetime slice(时间片)(时间片)(时间片)(时间片):q:q user numuser num(用户数)(用户数)(用户数)(用户数):n:n response timeresponse time(响应时间)(响应时间)(响应时间)(响
36、应时间):t:t t=nqt=nqvvMode:multi-terminalsMode:multi-terminals、multi-windowsmulti-windowsOPERATING SYSTEM OVERVIEWBatch Multiprogramming vs Timer SharingBatch Multiprogramming vs Timer SharingBatch Multiprogramming Time Sharing Principal Principal objectiveobjective Maximize Maximize processor useproce
37、ssor use Minimize Minimize response timeresponse time Source of Source of instruction to instruction to operating systemoperating system Job control Job control language language commands commands provided with the provided with the jobjob Commands Commands entered at the entered at the terminalterm
38、inal OPERATING SYSTEM OVERVIEWReducing the Swapping Loads by Partial SwappingReducing the Swapping Loads by Partial Swapping(p59p59)Reducing the spending for accessing disk OPERATING SYSTEM OVERVIEW1.3 Major Achievements1.3 Major Achievements(p60p60)1.3.1 Processes(1.3.1 Processes(进程进程进程进程)1.3.2 Mem
39、ory management1.3.2 Memory management1.3.3 Information protection and security1.3.3 Information protection and security1.3.4 Scheduling and resource management1.3.4 Scheduling and resource management1.3.5 System structure1.3.5 System structureOPERATING SYSTEM OVERVIEW1.3.1 Processes1.3.1 Processesvv
40、A program in executionA program in executionvvThe animated spiritThe animated spirit(活动精灵)(活动精灵)(活动精灵)(活动精灵)of a program of a programvvThe entityThe entity(实体)(实体)(实体)(实体)that can be assigned that can be assigned(分派)(分派)(分派)(分派)to and to and executed on a processorexecuted on a processorvvThree majo
41、r types of computer systemThree major types of computer system Multiprogramming batch operationMultiprogramming batch operation Time sharingTime sharing Real-time transactionReal-time transaction(处理)(处理)(处理)(处理)systems systemsOPERATING SYSTEM OVERVIEWErrors May Happen in MultiprogrammingErrors May H
42、appen in MultiprogrammingvImproper synchronizationImproper synchronization(同步)(同步)(同步)(同步):Signals being:Signals being lost or duplicatelost or duplicate(重复)(重复)(重复)(重复)signals being received.signals being received.vFailed mutual exclusionFailed mutual exclusion(失败的互斥失败的互斥失败的互斥失败的互斥)vNondeterminateN
43、ondeterminate(不确定)(不确定)(不确定)(不确定)program operation program operation:The result is not uniqueThe result is not uniquevDeadlocksDeadlocks(死锁)(死锁)(死锁)(死锁)vTo solute these problems,introduce process conceptTo solute these problems,introduce process conceptOPERATING SYSTEM OVERVIEW Process entity(Proces
44、s entity(实体实体实体实体)vAn executable programAn executable programvThe associated data needed by the programThe associated data needed by the programvThe execution context(The execution context(上下文上下文上下文上下文)of the program)of the programOPERATING SYSTEM OVERVIEWProcess Image and Process SwitchProcess Imag
45、e and Process Switch(切换)(切换)(切换)(切换)(p63)(p63)OPERATING SYSTEM OVERVIEW1.3.2 Memory Management1.3.2 Memory ManagementvProcess isolationProcess isolation(隔离)(隔离)(隔离)(隔离)vAutomatic allocation and managementAutomatic allocation and managementvSupport of modularSupport of modular(模块化)(模块化)(模块化)(模块化)prog
46、ramming programmingvVirtually memoryVirtually memoryvLong-term storageLong-term storagevProtection and access controlProtection and access control(访问控制)(访问控制)(访问控制)(访问控制)OPERATING SYSTEM OVERVIEWFig 2.10 Two Views of a Storage SystemVirtual ProcessorReal ProcessorMapper(AddressTranslate)Main MemoryA
47、uxiliaryMemoryVirtualMemoryFiles(a)Users View(b)Operating System Designers ViewVirtualAddressMemoryAddressSwappingRead,WriteCopyLong-term StoreOPERATING SYSTEM OVERVIEW1.3.3 Information Protection and Security1.3.3 Information Protection and SecurityvAccess controlAccess control:for various resource
48、s in the system:for various resources in the systemvInformation flow controlInformation flow control(信息流控)(信息流控)(信息流控)(信息流控):to:to guarantee the data to send to destinationguarantee the data to send to destinationvCertificationCertification(认证)(认证)(认证)(认证)OPERATING SYSTEM OVERVIEW1.3.4 Scheduling an
49、d Resource Management1.3.4 Scheduling and Resource Management(p66p66)vvThree factors must be considerThree factors must be consider FairnessFairness Differential responsivenessDifferential responsiveness(区分服务区分服务区分服务区分服务):):e.g.e.g.If a process is If a process is waiting for the use of an I/O device
50、,the operating system waiting for the use of an I/O device,the operating system may wish to schedule that process for execution as soon as may wish to schedule that process for execution as soon as possible in order to free up the device for later demands possible in order to free up the device for