




已阅读5页,还剩73页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Lecture 2 The Structure of Operating System,操作系统的构件 整体式结构的操作系统 层次式结构的操作系统 虚拟机结构的操作系统 客户/服务器与微内核结构的操作系统 操作系统的运行模型,操作系统结构,2,操作系统结构设计概述,操作系统设计呈现出以下特征: 复杂程度高 生成周期长 正确性难保证 操作系统结构设计有两层含义 研究操作系统程序的数据结构和控制结构; 组成操作系统程序的构造过程和方法。采用不同的构件和构造方法可组成不同结构的操作系统。,操作系统结构,3,操作系统设计目标 可靠性 正确性 困难:并发性、共享性、随机性(中断) 健壮性,操作系统结构,4,高效性 多道程序设计的目标是提高资源利用率,但系统开销加大 Tu:运行目态程序所用的时间 Tsu:运行管态程序为用户服务所用的时间 Tsm:运行管态程序做系统管理工作所用的时间 系统运行效率: =(Tu+Tsu)/(Tu+Tsu+Tsm),操作系统结构,5,易维护 易读性 易扩充性 易修改性 易裁减性 易移植性 安全性 可适应性 简明性,操作系统结构,6,操作系统的结构设计 设计一个操作系统主要包括: 功能设计 算法设计 结构设计 结构设计 按照系统的功能和特性要求,选择合适的结构,使用相应的结构设计方法将系统逐步地分解、抽象和综合,使操作系统结构清晰、简单、可靠、易读、易修改,而且使用方便,适应性强,操作系统结构,7,操作系统的构件,内核 进程 线程 管程,操作系统结构,8,内核 内核是提供支持系统运行的基本功能的一组程序模块,有了内核的支撑,进程运行环境得到改善,安全性得到保证,系统效率就能提高。 分类:微内核和单内核。 Linux是单内核操作系统 ,Mach是微内核操作系统 ,Windows2000/XP改进的C/S结构 。,操作系统结构,9,内核提供的功能 中断处理 进程调度 原语管理 内核的执行的属性 内核是由中断驱动 内核的执行是连续的 内核在屏蔽中断状态下执行 内核可以使用特权指令,操作系统结构,10,内核被触发和内核处理流程,操作系统结构,11,内核和裸机组成了一台虚拟机具有以下特性: 虚拟机没有中断, 虚拟机为每个进程提供了一台虚拟处理器, 虚拟机为进程或模块提供了功能较强的指令系统。,操作系统结构,12,进程 进程是并发程序设计的一个工具,并发程序设计支撑了多道程序设计 进程使OS结构变得清晰 一个进程到另一个进程的控制转移由进程调度机构统一管理,不能杂乱无章,随意进行。 进程间的信号发送、消息传递和同步互斥由通信及同步机制完成,进程无法有意或无意破坏其它进程的数据。每个进程相对独立,相互隔离,提高了系统的安全性和可靠性。 进程结构较好刻画了系统的并发性,动态地描述出系统的执行过程,具有进程结构的操作系统,结构清晰、整齐划一,可维护性好。,操作系统结构,13,Components related to processes and threads include the following. Address space contents Registers Program counter Stack pointer State of system call(s) All related threads of execution All files from the process and their state (open or closed).,Process Management,操作系统结构,14,Process/thread management includes the following responsibilities. Creating a process Identifying the type of process Support process migration Scheduling Querying a process about its status Process status reporting,操作系统结构,15,There are three important functions related to process management. The function of exec: creates a new process including the process descriptor, through a remote procedure call (RPC) to the processor who is requesting the process to be executed. The function of getload: returns CPU speed, load, and amount of free memory to assist process migration. The function of stun: normal stun asks the process to finish work immediately and reply. An emergency stun stops the process immediately and does not wait for reply.,操作系统结构,16,Types of Processes From the point of view of a distributed operating system, there are two types of processes, divisible and indivisible. Divisible processes: Process may be sub-divided into smaller sub-processes or tasks (threads). The entire job is complete only if all tasks are complete. Indivisible processes: All processes are independent, indivisible, and may be of different sizes.,操作系统结构,17,Load Distribution and Process Migration Load balancing strives for an equal load throughout the system (hard to achieve). Load sharing only strives to assist overloaded resources. Load sharing or load balancing can be achieved in one of two ways, static or dynamic. Static: when processes were created, the load factor is used to decided where the process will be executed. Dynamic: the load factor is checked even after the processes have been created. When the load is heavily skewed, some processes (in execution) are moved away from the heavily loaded CPUs. Moving running processes is called process migration.,操作系统结构,18,Two components to a load-distributing algorithm: information gathering: responsible for deciding what information to collect, gathering the information, and selecting a suitable migration partner. process selection: responsible for deciding which process(es) to migrate. Information gathering: The most successful information-gathering algorithms collect information on-demand, or when the status changes by a pre-determined amount (e.g. 10% CPU load).,操作系统结构,19,Load index: what does it mean by load of a processor? CPU busy time CPU queue memory used average job response time paging, swaping queue average I/O time,操作系统结构,20,Process migration involves a lot of other issues. Are all processes considered equal or do some processes have higher priority? Do resources identify themselves as idle or is the availability determined by identifying a CPU being idle for x microseconds?,操作系统结构,21,How do we know how long a resource will be idel? What happens the load change in a short period of time? If we do not seek or find idle processors, how do we estimate the load of a particular location? Is this estimate statically or dynamically calculated? Will the migration improve the local performance of other processes? Will it negatively affect the remote location?,操作系统结构,22,Is the regular user of the remote resource able to kill migrated processes? Is the regular user able to force a process to migrate to another location? What is the risk of system failure during process migration? Is participation in load distribution voluntary or mandatory?,操作系统结构,23,Process selection: After identifying the resource, the second component is to select a process or processes to migrate. Cost of the migration: moving a running process includes at least the following. Copy the image (program) to the new location. Copy the data segment to the new location. Copy the process status (register values, stacks, PC) May have to copy external files. May have to send the results back to the original host. Maintain communications with the rest of the system, similar to the postal office mail forwarding system.,操作系统结构,24,How to copy information to the new location: Copy on demand (like page fault). Pre-emptive copy, partial or complete. The issue of heterogeneous system, hardware or software. We may have to marshal data as well as the code segment for the new location. This is very costly.,操作系统结构,25,In both components, information-gathering and process-selection, the question of centralized or distributed algorithm will come up.,操作系统结构,26,Process Scheduling,Process scheduling is an important part of any kernel. The key difference in process scheduling between a single-processor system and a distributed system is that cost of communication in distributed system is much higher than in a single-processor system. Specific detailed issues of scheduling will be discussed in later chapters.,操作系统结构,27,Processes Scheduling Paradigms Polling based: The scheduler has a complete list of processes that may need systems serices. The scheduler loops around and asks if services are needed. Interrupt based: Whenever a process needs to use the CPU, it sends an interrupt signal to the CPU. The scheduler will decide what to do with it. The process may be serviced immediately or it may be put into an appropriate queue.,操作系统结构,28,Scheduler Organization Precedence relationship: Processes and threads required by a particular job may depend on each other. They may have to follow a particular order (e.g. get into the car, put on the seat belt, start the engine, then drive). Without following the order, the results may be incorrect. This order is called a precendence relation. Gang scheduling: All related processes and threads are scheduled together.,操作系统结构,29,State-driven scheduler: All aspects of the process for a specific state are scheduled. When a state is complete, the scheduler then schedules the appropriate processes for next state. If no precedence relationship is present the scheduler organization may employ algorithsm similar to its single-processor counterpart, such as round-robin, first-come-first-serve, or priority scheduling.,操作系统结构,30,线程 进程是系统进行保护和资源分配的单位,而线程则是进程中一条执行路径,每个进程中允许有多个并行执行的路径,线程才是系统进行调度的单位。,操作系统结构,31,每个线程的内容 每个进程的内容 程序计数器 地址空间 堆栈 全局变量 寄存器组 打开文件 子线程 子进程 状态 定时器 信号 信号量 记帐信息,线程和进程的内容比较,2.10 线程,操作系统结构,32,2.10 线程,操作系统结构,33,Processes And Threads,A process is a program in execution. A process has three components, the text segment (or the code segment) which is the executable program itself, the data segment which contains the global data and the stack segment which is used to support function/procedure calls. A thread is an execution entity that has its own stack, PC and data segment. Threads share the code segment.,操作系统结构,34,Multi-threaded Processes Each process runs independently utilizing a single address space and a single thread of control. Threads share the address space and global variables, but have indepdent program count and stacks. There is no protection barrier for the shared address space and the global variables.,操作系统结构,35,Multithreaded Process Paradigms There are three common paradigms to utilize for structuring threads belonging to the same parent process. Specialist paradigm: All threads are equal partners, each with its own speciality. Client/server paradigm: Clients request specific services from server(s). Assembly line paradigm: The output of one thread is the input of the next.,操作系统结构,36,Multithreaded Support Thread support may be provided by the OS kernel. The kernel maintains a thread-status information table in protected memory. The table maintains the state of all threads. It has one entry per thread. The information includes state, priority, register values, and others.,操作系统结构,37,Thread support may also be implemented in the user space. The same type of information for threads are stored but not in the protected memory. Similarily the scheduling, management and support for the thread execution are provided by user programs.,操作系统结构,38,Comparison of the two methods (kernel vs. user) Kernel implementation is more efficient since the kernel has direct access to all resources. Kernel implementation is more secure. Kernel implementation is less flexible. Kernel implementation is not as scable.,操作系统结构,39,POSIX Standard for Threads POSIX (Portable Operating System Interface) has a set of standards for thread operation.,操作系统结构,40,操作系统结构,41,管程 管程:记录、协调各进程对临界资源的使用要求,供进程实现同步与互斥,并完成对共享变量的修改。 管程是管理共享资源的机制,对管程的调用表示对共享资源的请求与释放。管程应包含条件变量,当条件不满足时,可以通过对条件变量做延迟操作使调用进程等待,直到另一个进程调用管程过程并执行一个释放操作为止。,操作系统结构,42,操作系统结构,43,操作系统体系结构分类,整体式结构 层次式结构 虚拟机结构 客户服务器及微内核结构,操作系统结构,44,Kernel Types,Monolithic kernel Monolithic systems have a large kernel that include most operating system services, typically containing process, memory, file, name, and device management as well as interprocess communication.,操作系统结构,45,Layered kernel Layered kernels have divisible modular design.,操作系统结构,46,micro-kernel,操作系统结构,47,整体式结构的操作系统 操作系统的整体式结构又叫模块组合法,早期操作系统(如IBM操作系统)采用这种结构设计方法, 主要设计思想:模块接口法,无序模块法,模块组合法,操作系统结构,48,主要设计步骤:首先确定操作系统的总体功能,然后将总功能分解为若干个子功能,实现每个子功能的模块称为模块。继续分解,直至每个模块仅包含单一功能为止。最后通过接口将所有模块连接起来形成一个整体 特点:根据功能划分模块 数据基本上作为全局量使用 在系统内部,不同模块的程序之间可以不加控制地互相调用和转移 信息的传递方式可以根据需要随意约定,因而造成模块间的循环调用,操作系统结构,49,优点:结构紧密;接口简单直接;模块之间转接的灵活性使系统效率高; 缺点: 由于模块之间可以任意相互调用,形成网络,各模块互相联系,独立性差,系统结构不清晰。 数据作为全局量处理,系统内各模块均可对其进行存取和修改,造成模块间更为隐蔽的关系。使得难于对软件结构作出综合性的理解,难于修改,可靠性、易读性、适应性难以保证,操作系统结构,50,结论:可适应性较差,适用于规模较小、使用环境比较稳定却要求效率较高的系统,操作系统结构,51,层次式结构的操作系统 层次结构是把操作系统划分为内核和若干模块(或进程),这些模块(或进程)按功能的调用次序排列成若干层次,各层之间只能是单向依赖或单向调用关系,这样不但系统结构清晰,而且不构成循环。,操作系统结构,52,层次结构的全序和半序式 层次结构的由底向上方法和自顶向下方法,操作系统结构,53,构造层次结构OS分层原则 把与机器硬件有关的程序模块放在最底层 反映系统外特性的软件放在最外层 按照实现操作系统命令时模块间的调用次序或按进程间单向发送信息的顺序来分层 为进程的正常运行创造环境和提供条件的内核程序应该尽可能放在底层。,操作系统结构,54,层次结构的优点:整体问题局部化,系统的正确性可通过各层正确性来保证。增加、修改或替换层次不影响其他层次,有利于系统的维护和扩充。 层次结构是分层单向依赖的,必须要建立模块(进程)间的通信机制,系统花费在通信上的开销较大,系统的效率也就会降低。,操作系统结构,55,THE系统第一次提出层次结构设计方法 第0层完成中断处理、定时器管理和处理器调度。 第1层内存和磁鼓管理,为进程分配内存空间,并自动实现内存和磁鼓对换区的数据交换。 第2层处理进程与操作员间的通信,为每个进程生成虚操作员控制台。 第3层I/O管理,管理信息缓冲区。 第4层用户(进程)层。 第5层系统操作员(进程)层。,操作系统结构,56,Level Name Objects Example Operations 13 Shell User programming Statements in shell language environment 12 User processes User processes Quit, kill, suspend, resume 11 Directories Directories Create, destroy, attach, detach, search, list 10 Devices External devices, such Open, close, as printer, displays read, write and keyboards 9 File system Files Create, destroy, open, close, read, write 8 Communications Pipes Create, destroy, open , close, read, write,操作系统结构,57,Level Name Objects Example Operations 7 Virtual Memory Segments, pages Read, write, fetch 6 Local secondary Blocks of data, device Read, write, allocate, free store channels 5 Primitive processes Primitive process, Suspend, resume, semaphores, wait, signal ready list 4 Interrupts Interrupt-handling Invoke, mask, programs unmask, retry Procedures Procedures, call stack, Mark stack, call, return display 2 Instruction Set Evaluation stack, micro- Load, store, add, subtract program interpreter, branch scalar and array data 1 Electronic circuits Registers, gates, buses, Clear, transfer, activate, etc. complement,操作系统结构,58,虚拟机结构的操作系统 基于如下思想,一个分时系统应该提供以下特性: 多道程序, 一个具有比裸机更方便、界面扩展的计算机。 VM/370的主旨在于将此二者彻底地隔离开来。,操作系统结构,59,物理计算机资源通过多重化和共享技术可改变成多个虚拟机。 基本做法:通过用一类物理设备来模拟另一类物理设备,或通过分时地使用一类物理设备,把一个物理实体改变成若干个逻辑上的对应物。物理实体是实际存在的,而逻辑上的对应物是虚幻的、感觉上的。,操作系统结构,60,操作系统结构,61,客户服务器及微内核结构 客户/服务器与微内核结构 客户/服务器结构的思想:将操作系统分成两大部分, 一是运行在用户态并以C/S方式活动的进程; 二是运行在核心态的内核。,操作系统结构,62,客户/服务器结构的思想 每个进程实现一类服务,称服务器进程(如文件服务、进程管理服务、存储管理服务、网络通信服务等)。它的任务是检查是否有客户提出服务请求,如果有请求则在满足客户的要求后返回结果,于是,用户进程与服务器进程形成了C/S关系。 运行在核心态的内核把该消息传给服务器;服务器执行相应操作,再通过内核用消息把结果返回给用户。内核只实现极少任务,主要起信息验证、交换的作用,因而,称微内核(Microkernel),这种结构也就称为客户/服务器与微内核结构。,操作系统结构,63,客户/服务器与微内核 结构操作系统,操作系统结构,64,微内核结构的优点有: 一致性接口 可扩充性 可移植性 可靠性 支持分布式系统 支持面向对象的操作系统,操作系统结构,65,微内核的设计 基本的存储管理 微内核支持内核外部的页面管理和虚存管理: 转让(Grant) 映射 (Map) 刷新(Flush),操作系统结构,66,内核外的页面管理程序做缺页处理,操作系统结构,67,进程间通信 微内核操作系统中,进程和线程通信的基本形式是消息。进程间通信基于进程间相关联的端口(Ports),一个端口是一个特定进程的消息队列,与端口相关的是一张能力表,记录了可以与这个进程通信的进程。,操作系统结构,68,I/O和中断管理,driver thread; do wait for (mhg, sender); if sender = my_hardware_in
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025学前班教育发展
- 2024年光导纤维导光环项目投资申请报告代可行性研究报告
- 2024年AFC售检票系统项目投资申请报告代可行性研究报告
- 2023 年医院招聘护士考试题库及参考答案
- 江苏省宿迁市沭阳中学等三校2024-2025学年高三下学期4月联考政治试题(含解析)
- 2024-2025学年江西省新余市仙女湖区八年级(下)期末语文试卷
- 2025江西中考化学试题卷
- 幼儿园小班数学教案《找圆形》
- 2025年中小学心理健康教育教师考试试题及答案
- 保密协议、竞业禁止协议与培训
- 感染性疾病分子诊断试剂行业深度调研及发展战略咨询报告
- GB/T 45355-2025无压埋地排污、排水用聚乙烯(PE)管道系统
- 安全生产风险防控课件
- ISO45001 2024职业健康安全管理体系要求及使用指南
- 2025年湖南株洲南方中学自主招生英语试卷真题(含答案详解)
- 劳务绿化合同范本
- 2025年云南黄金矿业集团股份有限公司招聘笔试参考题库含答案解析
- 基于BOPPPS框架与线上线下混合教学模式的探索
- 中国瑜伽服市场需求现状调研及未来营销趋势研究报告
- DB32-T 186-2015建筑消防设施检测技术规程
- 外呼培训心得
评论
0/150
提交评论