Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3: Operating-System Structures操作系统结构

Similar presentations


Presentation on theme: "Chapter 3: Operating-System Structures操作系统结构"— Presentation transcript:

1 Chapter 3: Operating-System Structures操作系统结构
3.1 System Components系统部件 3.2 Operating System Services操作系统服务 3.3 System Calls 系统调用 3.4 System Programs系统程序 3.5 System Structure 系统结构 3.6 Virtual Machines 虚拟机 3.7 System Design and Implementation系统设计和实现 3.8 System Generation系统生成 Operating System Concepts

2 3.1 System Components 系统部件
3.1.1 Process Management进程管理 3.1.2 Main Memory Management主存管理 3.1.3 File Management文件管理 3.1.4 I/O System Management I/O系统管理 3.1.5 Secondary Management二级储存器管理 3.1.6 Networking网络处理 3.1.7 Protection System保护系统 3.1.8 Command-Interpreter System命令解释系统 Operating System Concepts

3 3.1.1 Process Management进程管理
主要任务:是对处理机进行分配并对其运行实施有效管理。对处理机的管理,可归结为对进程的管理。 进程管理包括以下四方面功能: 进程控制、进程同步、进程通信、进程调度 A process is a program in execution. A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task.   进程是正在执行的程序。为了完成其任务,进程需要一定的资源,包括CPU时间,存储器,文件,以及I/O设备 Program is inactive entity Process is active entity with a program counter Operating System Concepts

4 Process Management The operating system is responsible for the following activities in connection with process management. 在同进程管理有关的活动中,操作系统负责下列事务: Process creation and deletion.进程创建和删除 process suspension and resumption.进程挂起和恢复 Provision of mechanisms for:可提供以下有关机制: process synchronization进程同步 process communication进程通信 deadlock handling死锁处理 Discuss in Chap 4--8 Operating System Concepts

5 3.1.2 Main-Memory Management 主存管理
Memory is a large array of words or bytes, each with its own address. It is a repository of quickly accessible data shared by the CPU and I/O devices. 存储器是字或字节的一个大数组,每一字或字节有自己的地址。它是一个可被CPU和I/O 共享、可快速存取数据的存放地 Main memory is a volatile storage device. It loses its contents in the case of system failure. 主存储器是一个易失性存储设备。系统失败时,会丢失其内容 Operating System Concepts

6 Main-Memory Management (Cont.)
The operating system is responsible for the following activities in connections with memory management:  在同存储管理有关的活动中,操作系统负责下列事务: Keep track of which parts of memory are currently being used and by whom.  保持记录存储器的哪一部分当前被使用以及被谁使用 Decide which processes to load when memory space becomes available.  当有可用存储空间时,决定调入哪个进程 Allocate and deallocate memory space as needed.   需要时分配和收回存储空间 Discuss in Chap 9--10 Operating System Concepts

7 3.1.3 File Management文件管理 A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data.  文件是由其创建者定义的关联信息的一个收集器(集合),通常文件表示程序(源程序和目标程序)和数据 The operating system is responsible for the following activities in connections with file management: 在同文件管理有关的活动中,操作系统负责下列事务: File creation and deletion. 文件创建和删除 Directory creation and deletion.目录创建和删除 Operating System Concepts

8 File Management (Cont.)
Support of primitives for manipulating files and directories. 支持操纵文件和目录的原语 Mapping files onto secondary storage.  把文件映象到二级存储器 File backup on stable (nonvolatile) storage media.  在稳定(非易失性)存储介质做文件备份 Discuss in Chap Operating System Concepts

9 3.1.4 I/O System Management I/O系统管理
The I/O system consists of: I/O 系统包括 A buffer-caching system 缓冲区-高速缓存系统 A general device-driver interface 通用设备驱动器接口 Drivers for specific hardware devices 用于特定硬件设备的驱动程序 Discuss in Chap 13 Operating System Concepts

10 3.1.5 Secondary-Storage Management 二级存储管理
Since main memory (primary storage) is volatile and too small to accommodate all data and programs permanently, the computer system must provide secondary storage to back up main memory.  由于主存(基本存储器)是易失性的,而且太小不足以永久保存所有的数据和程序,计算机系统必须提供二级存储器备份主存 Most modern computer systems use disks as the principle on-line storage medium, for both programs and data.    多数现代计算机系统采用磁盘作为程序和数据的基本联机存储介质 Operating System Concepts

11 Secondary-Storage Management (Cont.)
The operating system is responsible for the following activities in connection with disk management:  在同磁盘管理有关的活动中,操作系统负责下列事务: Free space management空闲空间管理 Storage allocation存储分配 Disk scheduling磁盘调度 Discuss in Chap 14 Operating System Concepts

12 3.1.6 Networking (Distributed Systems) 网络处理(分布式系统)
A distributed system is a collection processors that do not share memory or a clock. Each processor has its own local memory. 分布式系统是一组不共享存储器或时钟的处理器集合,每个处理器有自己的内存 The processors in the system are connected through a communication network. 系统中的处理器通过通信网络连接 Communication takes place using a protocol. 使用协议进行通信 Operating System Concepts

13 Networking (Distributed Systems) (Cont.)
A distributed system provides user access to various system resources. 分布式系统提供用户访问各种系统资源 Access to a shared resource allows: 对共享资源的访问可以实现: Computation speed-up加速运算 Increased data availability提高数据利用性 Enhanced reliability 增强可靠性 Discuss in Chap Operating System Concepts

14 3.1.7 Protection System 保护系统
Protection refers to a mechanism for controlling access by programs, processes, or users to both system and user resources. 保护是一种机制,控制程序、进程、或用户对系统和用户资源的访问 The protection mechanism must:保护机制必须 distinguish between authorized and unauthorized usage. 区分授权和非授权使用 specify the controls to be imposed. 确定要采用的控制 provide a means of enforcement. 提供强制手段 Discuss in Chap Operating System Concepts

15 3.1.8 Command-Interpreter System 命令解释系统
Many commands are given to the operating system by control statements which deal with: 操作系统有许多命令,可以通过控制语句处理: process creation and management 进程创建和管理 I/O handling 处理I/O secondary-storage management 二级存储管理 main-memory management 主存管理 file-system access文件访问 protection 保护 networking 网络 Operating System Concepts

16 Command-Interpreter System (Cont.)
The program that reads and interprets control statements is called variously: 读入和解释控制语句的程序有各种名称 command-line interpreter命令行解释器 shell (in UNIX) Its function is to get and execute the next command statement. 其功能是获得和执行下一个命令语句 Operating System Concepts

17 3.2 Operating System Services 操作系统服务
Program execution – system capability to load a program into memory and to run it. 程序执行 - 调入一个程序进入内存并运行之的系统能力 I/O operations – since user programs cannot execute I/O operations directly, the operating system must provide some means to perform I/O. I/O操作 - 由于用户程序不能直接执行I/O操作,操作系统必须提供完成I/O操作的手段 File-system manipulation – program capability to read, write, create, and delete files. 文件系统操纵 – 程序能够读、写、创建和删除文件 Operating System Concepts

18 Operating System Services (Cont.)
Communications – exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing. 通信 - 运行的进程间在同一计算机或由网络连接的不同系统中交换信息。通过共享存储器或消息传递实现 Error detection – ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs. 出错检测 – 通过探测在CPU与内存硬件中,在I/O设备中,或在用户程序中的错误,确保正确运算 Operating System Concepts

19 Additional Operating System Functions 其他操作系统功能
Additional functions exist not for helping the user, but rather for ensuring efficient system operations. 其他的功能不是用于帮助用户,而是为了系统效率: Resource allocation – allocating resources to multiple users or multiple jobs running at the same time. 资源分配 - 把资源分配给多个用户或多个同时运行的作业 Accounting – keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics. 帐务 - 跟踪和记录用户对资源的使用,用于帐单和统计 Protection – ensuring that all access to system resources is controlled. 保护 - 确保对资源的所有访问均在控制中 Operating System Concepts

20 3.3 System Calls 系统调用 System calls provide the interface between a running program and the operating system. 系统调用提供在运行程序和操作系统之间的接口 Generally available as assembly-language instructions. 通常以汇编语言指令形式提供 Languages defined to replace assembly language for systems programming allow system calls to be made directly (e.g., C, C++) 替代汇编语言的、供系统编程的语言,允许直接使用系统调用 Operating System Concepts

21 System Calls (Cont.) Three general methods are used to pass parameters between a running program and the operating system. 3种常用方式用于在运行程序和操作系统之间的参数传递 Pass parameters in registers. 寄存器中的参数传递 Store the parameters in a table in memory, and the table address is passed as a parameter in a register. 参数存在内存的一张表中,表地址作为寄存器的参数传递 Push (store) the parameters onto the stack by the program, and pop off the stack by operating system. 程序把参数压入栈,由操作系统弹出 Operating System Concepts

22 Fig 3.1 Passing of Parameters As A Table 表格方式的参数传递
Operating System Concepts

23 Types of System Calls 系统调用类型
Process control 进程控制 File management 文件管理 Device management 设备管理 Information maintenance 信息维护 Communications 通信 Operating System Concepts

24 Fig 3.3 MS-DOS Execution MS-DOS运行
At System Start-up Running a Program Operating System Concepts

25 Fig 3.4 UNIX Running Multiple Programs UNIX运行多个程序
Operating System Concepts

26 Fig 3.5 Communication Models通信模式
Communication may take place using either message passing or shared memory. Msg Passing消息传递 Shared Memory共享内存 Operating System Concepts

27 3.4 System Programs系统程序 System programs provide a convenient environment for program development and execution. The can be divided into:  系统提供程序开发和执行的便利环境。可划分为: File manipulation 文件操纵 Status information 状态信息 File modification 文件修改 Programming language support 程序设计语言支持 Program loading and execution 程序调入和执行 Communications 通信 Application programs 应用程序 Operating System Concepts

28 System Programs (Cont.)
Most users’ view of the operation system is defined by system programs, not the actual system calls.  操作系统,多数用户观点(角度)是由系统程序定义而不是实际的系统调用 Operating System Concepts

29 3.5 System Structure系统结构 3.5.1 Simple Structure
MS-DOS – written to provide the most functionality in the least space   MS-DOS-以最小的空间提供最多的功能 not divided into modules 不划分模块 Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated  尽管MS-DOS有某种结构,其接口和功能层没有划分清楚 Operating System Concepts

30 Fig 3.6 MS-DOS Layer Structure MS-DOS层次结构
Operating System Concepts

31 UNIX System Structure UNIX 系统结构
UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts.  UNIX - 受硬件功能限制,早期UNIX只是有限的结构化。 UNIX包括2个分离的部分 Systems programs系统程序 The kernel内核 Consists of everything below the system-call interface and above the physical hardware 包括了在物理硬件之上,系统调用之下的一切 Operating System Concepts

32 UNIX System Structure (Cont.)
Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level. 提供文件系统、 CPU调度、存储管理、和其他操作系统功能 ;每一层有大量的功能 Operating System Concepts

33 Fig 3.7 UNIX System Structure UNIX系统结构
Operating System Concepts

34 3.5.2 Layered Approach 层次化结构
The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.  操作系统划分为若干层,在低层上构建高层。底层(0层)为硬件;最高层( N层)为用户层 With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers.  考虑模块化,层的选择是每层只使用低层次的功能和服务 Operating System Concepts

35 Fig 3.8 An Operating System Layer 操作系统层
Operating System Concepts

36 Layered Structure of the THE OS THE OS的层次化结构
A layered design was first used in THE operating system. Its six layers are as follows: THE操作系统首先使用层次化设计。有如下六层: Operating System Concepts

37 Fig 3.9 OS/2 Layer Structure OS/2层次化结构
Operating System Concepts

38 3.5.3 Microkernel  微内核 Moves as much from the kernel into “user” space. 从内核中移动很多(模块)到“用户”空间(内核以外的地方) Communication takes place between user modules using message passing. 利用消息传递实现用户模块间的通信 Benefits: - easier to extend a microkernel 容易扩充微内核 - easier to port the operating system to new architectures 容易移植操作系统到新的结构中 - more reliable (less code is running in kernel mode) 更可靠 - more secure 更安全 Operating System Concepts

39 Fig 3.10 Windows NT Client-Server Structure  Windows NT 客户机-服务器结构
Operating System Concepts

40 3.6 Virtual Machines 虚拟机 A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware. 虚拟机是层次化的逻辑结果。它把硬件和操作系统内核看成都是硬件 A virtual machine provides an interface identical to the underlying bare hardware.  虚拟机为裸机提供了统一的接口 The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory.  操作系统创建了多个进程,每一个进程有自己的处理器和(虚拟)内存 Operating System Concepts

41 Virtual Machines (Cont.)
The resources of the physical computer are shared to create the virtual machines.  物理计算机的资源被共享,以创建虚拟机 CPU scheduling can create the appearance that users have their own processor.  CPU调度使得用户好像有自己的处理器 Spooling and a file system can provide virtual card readers and virtual line printers.  Spooling和文件系统提供了虚拟卡片阅读机和打印机 A normal user time-sharing terminal serves as the virtual machine operator’s console.  普通用户终端成为虚拟机操作员的控制台 Operating System Concepts

42 Non-virtual Machine非虚拟机
Fig 3.11 System Models系统模式 Non-virtual Machine非虚拟机 Virtual Machine虚拟机 Operating System Concepts

43 Advantages/Disadvantages of Virtual Machines 虚拟机的优缺点
The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources.  虚拟机概念提供对系统资源的完全保护,因为每个虚拟机同其他虚拟机隔离。当然,隔离不允许直接共享资源 A virtual-machine system is a perfect vehicle for operating-systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation.  虚拟机是研发操作系统的完美载体。系统开发在虚拟机上而不是在物理硬件上完成,从而不会打扰正常系统运行 Operating System Concepts

44 Advantages/Disadvantages of Virtual Machines(Cont.)
The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine.  由于需要对下面的机器进行精确的复制,所以虚拟机的概念实现困难 Operating System Concepts

45 3.6.3 Java Virtual Machine Java虚拟机
Compiled Java programs are platform-neutral bytecodes executed by a Java Virtual Machine (JVM). JVM consists of - class loader - class verifier - runtime interpreter Just-In-Time (JIT) compilers increase performance Operating System Concepts

46 Fig 3.12 Java Virtual Machine Java虚拟机
Operating System Concepts

47 3.7 System Design and Implementation系统设计和实现
3.7.1 Design Goals User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast.  用户目标 - 操作系统应该便于使用,易学,可靠,安全并且快捷 System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient.  系统目标 - 操作系统应该容易设计、实现和维护,还要灵活、可靠、无错误和高效 Operating System Concepts

48 3.7.2 Mechanisms and Policies 机制和策略
Mechanisms determine how to do something, policies decide what will be done.  机制确定怎样做事,策略决定要做什么 The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later.  把策略从机制中分离是非常重要的,如果策略在后期要改变,它允许最大的灵活性 Operating System Concepts

49 3.7.3 System Implementation 系统实现
Traditionally written in assembly language, operating systems can now be written in higher-level languages.  传统上用汇编语言编写,现在可用高级语言编写 Code written in a high-level language:  用高级语言编写代码: can be written faster. 编码快 is more compact.更紧凑 is easier to understand and debug.容易理解和调试 An operating system is far easier to port (move to some other hardware) if it is written in a high-level language.  以高级语言编写的操作系统更容易移植 Operating System Concepts

50 3.8 System Generation (SYSGEN) 系统生成
Operating systems are designed to run on any of a class of machines; the system must be configured for each specific computer site. 操作系统被设计在任何类型的机器上运行;系统必须能在每一特定的机器上配置 SYSGEN program obtains information concerning the specific configuration of the hardware system. SYSGEN程序得到硬件系统特定配置的信息 Booting – starting a computer by loading the kernel.  自举 - 通过调入内核启动计算机 Bootstrap program – code stored in ROM that is able to locate the kernel, load it into memory, and start its execution. 自举程序 - 存储在ROM中的代码,能够定位内核,调入内存,并开始其运行 Operating System Concepts

51 3.9 Summary Operating System Concepts

52 Exercises 3.6 3.13 Operating System Concepts


Download ppt "Chapter 3: Operating-System Structures操作系统结构"

Similar presentations


Ads by Google