College of Computer Science Operating System College of Computer Science Zhejiang University Email:qfzhang@zju.edu.cn http://os.zju.edu.cn/linux/files/qfzhang/ Operating System Concepts
教学目的与任务 《操作系统》是计算机应用专业和计算机软件专业的专业基础课。 通过本课程的学习,要求学生理解操作系统在计算机系统中的作用、地位和特点,熟练掌握和运用操作系统在进行计算机软硬件资源管理和调度时常用的概念、方法、策略、算法、手段等。 通过外文教材的讲授和学习,使学生在专业英语资料的阅读和理解上达到应有的水平。 Operating System Concepts
教材、参考书、网址 教材: Operating System Concepts 6th, Abrraham Silberschatz、Peter Galvin,Greg Gagne,2001.6 实验:边干边学—Linux内核指导,李善平等,浙江大学出版社 中文参考书: 1. 《操作系统学习指导与考试指导》,李善平等,浙江大学出版社。 2.《计算机操作系统》,汤子瀛等,西安电子科技大学出版社。 3.《现代操作系统》,Aadrew S.T著,陈向群等译,机械工业出版社。 参考网址: www.bell-labs.com/topic/books/os-book www.bell-labs.com/topic/books/aos-book os.zju.edu.cn Operating System Concepts
操作系统资源网站 http://os.zju.edu.cn 论坛 答疑 习题布置、解答、提交、批阅 考试 参考资料 论坛 答疑 习题布置、解答、提交、批阅 考试 参考资料 Operating System Concepts
目录 Part 1 Overview Part 2 Process Management Part 3 Storage Management Chapter 1: Introduction引论 Chapter 2: Computer-System Structures计算机系统结构 Chapter 3: Operating-System Structures操作系统结构 Part 2 Process Management Chapter 4: Processes 进程 Chapter 5: Threads 线程 Chapter 6: CPU Scheduling CPU调度 Chapter 7: Process Synchronization 进程同步 Chapter 8: Deadlocks 死锁 Part 3 Storage Management Chapter 9: Memory Management 存储器管理 Chapter 10: Virtual Memory虚拟存储器 Chapter 11: File-System Interface文件系统接口 Operating System Concepts
目录-1 Part 4 I/O Management Part 5 Distributed Systems Chapter 12: File System Implementation文件系统实现 Chapter 13: I/O Systems I/O系统 Chapter 14: Mass-Storage Systems 海量存储系统 Part 5 Distributed Systems Chapter 15: Network Structures 网络结构 Chapter 16: Distributed-File Systems 分布式文件系统 Chapter 17: Distributed Coordination 分布式协同 Part 6 Protection and Security Chapter 18: Protection 保护 Chapter 19: Security 安全 Part 7 Case Study Chapter 20: The Linux System Linux系统 Chapter 21: Windows 2000 Operating System Concepts
Chapter 1: Introduction引论 1.1 What is an Operating System?什么是操作系统? 1.2 Mainframe Systems主机系统 1.3 Desktop Systems台式系统 1.4 Multiprocessor Systems多处理机系统 1.5 Distributed Systems分布式系统 1.6 Clustered System集群系统 1.7 Real -Time Systems实时系统 1.8 Handheld Systems手持系统 1.9 Feature Migration特征变迁 1.10 Computing Environments计算环境 Operating System Concepts
1.1 What is an Operating System? 什么是操作系统? A program that acts as an intermediary between a user of a computer and the computer hardware. 在计算机用户和计算机硬件之间起媒介作用的一种程序。 Operating system goals:操作系统目标 Execute user programs and make solving user problems easier. 执行用户程序并使用户问题更易解决。 Make the computer system convenient to use. 使计算机系统更易使用。 Use the computer hardware in an efficient manner. 以一种效率的方式使用硬件。 Operating System Concepts
Computer System Components 计算机系统部件 1. Hardware硬件– provides basic computing resources (CPU, memory, I/O devices).提供基本的计算资源 2. Operating system操作系统 – controls and coordinates the use of the hardware among the various application programs for the various users.在各种应用程序和用户之间控制与协调对硬件的使用 3. Applications programs应用程序– define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs).定义解决用户问题的资源使用方式(编译、数据库、视频游戏、事务程序等) 4. Users用户(people, machines, other computers). Operating System Concepts
Fig 1.1 Abstract View of System Components 系统部件的简要视图 Operating System Concepts
Operating System Definitions 操作系统定义 Resource allocator资源分配者– manages and allocates resources.管理和分配资源 Control program控制程序– controls the execution of user programs and operations of I/O devices . 控制用户程序的运行和I/O设备的操作 Kernel内核– the one program running at all times (all else being application programs). 在全时运行的一个程序(其他的是应用) Common definitions: operating system is the one program running at all times on the computer (usually called the kernel), with all else being application programs. 操作系统是管理和控制计算机各种硬件和软件资源,合理的组织计算机的工作流程 ,以及方便用户的程序的集合 Operating System Concepts
1.2 Mainframe Systems主机系统 Reduce setup time by batching similar jobs批量处理同类作业减少了设置时间 Automatic job sequencing自动作业调度– automatically transfers control from one job to another. First rudimentary operating system.自动把控制从一个作业转到另一个作业。第一个基本操作系统。 Resident monitor常驻管理程序 initial control in monitor初始化管理程序 control transfers to job把控制权移交给作业 when job completes control transfers pack to monitor作业完成后把控制权移交还给管理程序 Operating System Concepts
Fig 1.2 Memory Layout for a Simple Batch System 简单批处理系统的内存布局 Low CPU utilization Operating System Concepts
1.2.2 Multiprogrammed Systems 多道程序系统 Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them. 在主存中同时有若干个作业, CPU在其中多重切换(共享CPU)。 Increase CPU utilization Operating System Concepts
OS Features Needed for Multiprogramming多道程序对OS特点的要求 I/O routine supplied by the system.系统提供I/O例程 Memory management存储管理– the system must allocate the memory to several jobs. 系统必须为若干作业分派空间 CPU scheduling CPU调度 – the system must choose among several jobs ready to run. 系统必须在就绪作业中选择准备运行 Allocation of devices.设备分配 Operating System Concepts
1.2.3Time-Sharing Systems–Interactive Computing分时系统-交互式计算 The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory). 对保存在内存和磁盘上的若干作业之间共享CPU( CPU被分配给某个作业仅当该作业在内存) A job swapped in and out of memory to the disk. 作业在内存和磁盘之间被对换 所谓“分时”是指多个用户分时共享使用同一台计算机,也就是说把计算机的系统资源(尤其是CPU时间)进行时间上分割,即将整个工作时间分成一个个的时间片,每个时间片分给一个用户使用,这样将CPU工作时间分别提供给多个用户使用,每个用户依次地轮流且使用一个时间片。 Operating System Concepts
Time-Sharing Systems–Interactive Computing (Cont.) On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” from the user’s keyboard. 提供用户和系统之间的在线通信;操作系统完成了一条命令的执行后,它从用户键盘上寻找下一条控制语句 On-line system must be available for users to access data and code. 在线系统必须使用户能够访问数据和代码 Operating System Concepts
1.3 Desktop Systems台式系统 Personal computers个人计算机– computer system dedicated to a single user.供个人使用的计算机系统 I/O devices– keyboards, mice, display screens, small printers. I/O设备–键盘、鼠标、显示器、小型打印机 User convenience and responsiveness.方便用户和响应 Can adopt technology developed for larger operating system’ often individuals have sole use of computer and do not need advanced CPU utilization of protection features.可采用大型操作系统研发的技术,个人独占计算机不需要高级CPU使用的保护技术 May run several different types of operating systems (Windows, MacOS, UNIX, Linux)可以运行不同的操作系统 Operating System Concepts
1.4 Multiprocessor Systems多处理机系统 Multiprocessor systems (knows as parallel systems or tightly coupled systems) Multiprocessor systems with more than on CPU in close communication. 有紧密通信的、多于一个CPU的多处理器系统 Tightly coupled system 紧密偶合系统– processors share memory and a clock; communication usually takes place through the shared memory. 处理器共享内存和时钟;一般通过共享内存进行通信 Advantages of Multiprocessor system:优点 Increased throughput增大吞吐量 Economical经济 Operating System Concepts
Multiprocessor Systems(Cont.) Increased reliability提高可靠性 graceful degradation (fail-soft )故障弱化:ability to continue providing service proportional to the level of surviving hardware fault tolerant 容错 Symmetric multiprocessing (SMP)对称多处理 器 Each processor runs and identical copy of the operating system. 每个处理器运行操作系统的相同副本 Many processes can run at once without performance deterioration. 许多进程可以立即运行不会降低性能 Operating System Concepts
Multiprocessor Systems(Cont.) Most modern operating systems support SMP 多数现代操作系统支持SMP Asymmetric multiprocessing非对称多处理器 Each processor is assigned a specific task; master processor schedules and allocated work to slave processors. 每个处理器赋予一个特定任务;主处理器为从处理器调度和分配作业 More common in extremely large systems 常用在非常大的系统中 Operating System Concepts
Fig 1.4 Symmetric Multiprocessing Architecture 对称多处理器体系结构 Operating System Concepts
1.5 Distributed Systems分布式系统 Distribute the computation among several physical processors.计算分布在若干物理处理器上 Loosely coupled system– each processor has its own local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines.松散偶合系统–每个处理器有自身的本地存储器;通过各种通信设施,如高速总线、电话线等进行处理器之间的通信 Advantages of distributed systems.分布式系统优点 Resources Sharing资源共享 Computation speed up – load sharing 加快计算 - 共享装载 Operating System Concepts
Distributed Systems (cont.) Reliability可靠 Communications通信 Requires networking infrastructure.需要网络构架 Local area networks (LAN) or Wide area networks (WAN) May be either client-server客户/服务器or peer-to-peer systems.对等系统 Operating System Concepts
Fig 1.5 General Structure of Client-Server 客户/服务器一般结构 Operating System Concepts
1.6 Clustered Systems集群系统 Clustering allows two or more systems to share storage.集群允许两个或多个系统共享存储器 Provides high reliability.提供高可靠性 Asymmetric clustering(非对称集群) one server runs the application while other servers standby. 一个服务器运行应用程序时其他服务器备用 one host is hot standby mode while the other is running the application . The hot standby host does nothing but monitor the active server .当另一个服务器正在运行应用程序时,一个主机处在激活等待状态。该机不做任何工作,但监控运行的服务器 Symmetric clustering: all N hosts are running the application , and they are monitoring each other . 当所有的主机都运行应用程序时,他们相互监控。 Operating System Concepts
1.7 Real-Time Systems实时系统 Often used as a control device in a dedicated application such as controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems. 通常作为控制设备在诸如控制科学实验、医学影象系统、工业控制系统以及一些显示系统中应用 Well-defined fixed-time constraints. 严格确定的时间限制 Real-Time systems may be either hard or soft real-time.实时系统可以是硬实时或软实时 Hard real-time硬实时 : Secondary storage limited or absent, data stored in short term memory, or read-only memory (ROM) 有限的或没有次级存储器,数据存在短期存储器或只读存储器中 Operating System Concepts
Real-Time Systems (Cont.) Conflicts with time-sharing systems, not supported by general-purpose operating systems. 与分时系统不同,通用操作系统一般不支持实时系统 Soft real-time软实时 Limited utility in industrial control of robotics 在工业控制或机器人中有部分应用 Useful in applications (multimedia, virtual reality) requiring advanced operating-system features. 在需要高级操作系统功能的应用软件(多媒体、虚拟现实)中使用 Operating System Concepts
1.8 Handheld Systems手持系统 Personal Digital Assistants (PDAs)个人数字助理 : such as PalmPilots or Cellular telephones with connectivity to network such as the Internet . Issues:问题 Limited memory 内存限制 Slow processors 处理器速度慢 Small display screens 显示屏小 Operating System Concepts
1.9 Fig 1.6 Migration of Operating-System Concepts and Features操作系统概念和特性的变迁
1.10 Computing Environments 计算环境 1.10.1 Traditional computing传统的计算 1.10.2 Web-Based Computing基于Web计算 1.10.3 Embedded Computing嵌入计算 Operating System Concepts
1.11 Summary Concept of the Operating System Mainframe Systems主机系统 Desktop Systems台式系统 Multiprocessor Systems多处理机系统 Distributed Systems分布式系统 Real -Time Systems实时系统 Handheld Systems手持系统 Feature Migration特征变迁 Computing Environments计算环境 Operating System Concepts
习题: 1.操作系统是一种﹎﹎A﹎﹎,在操作系统中采用多道程序设计方式能提高CPU和外部设备的﹎﹎B﹎﹎。一般来说,为了实现多道程序设计,计算机需要有﹎﹎C﹎﹎。 A: (1)通用软件;(2)系统软件;(3)应用软件;(4) 软件包。 B: (1)利用效率;(2)可靠性;(3)稳定性;(4)兼容性。 C:(1)更大的内存;(2)更快的外部设备;(3)更快的CPU;(4)更先进的终端;() 2.分时系统中,为使多个用户能够同时与系统交互,最关键的问题是﹎﹎A﹎﹎,当用户数目为100时,为保证响应不超过2秒;此时的时间片最大应为﹎﹎B﹎﹎。 A:(1)计算机具有足够的运行速度;(2)内存容量应足够大;(3)系统能及时地接收多个用户输入;(4)能在一短的时间内,使所有用户程序都能运行;(5)能快速进行内外存对换。 B:(1)10ms;(2)20ms;(3)50ms;(4)100ms;(5)200ms。(解) Operating System Concepts
Exercises 1.3 1.5 1.6 1.9 Operating System Concepts
A、B、C:(1)灵活性和可适应性;(2)交互性和响应时间;(3)周转时间和系统吞吐量;(4)实时性和可靠性。 Operating System Concepts