Chapter 7 Operating Systems
OBJECTIVES After reading this chapter, the reader should be able to: Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the concept of virtual memory. Understand the concept of deadlock and starvation. List some of the characteristics of popular operating systems such as Windows 2000, UNIX, and Linux.
Contents 7.1 Definition 7.2 Evolution 7.3 Components 7.4 Popular Operating Systems Summary
7.1 DEFINITION
A computer is a system made of two major components: Hardware (HW) and Software (SW). Computer software is divided into the operating system (OS) and application programs (Apps.). Apps. Software Program OS Computer HW (Von Neumann Model) Hardware Input Data Output Data
HW---physical equipment. SW---The collection of programs that allow the HW to do its job. OS---control the access of HW by users. Apps.---Use the computer HW to solve user’s problems.
OS Common Definitions An OS is an interface between the HW and user (programs or humans). An OS is a program (or a set of programs) that facilitates the execution of other programs. An OS acts as a general manager supervising the activity of each component in the computer system. Apps. OS HW
Definition Note: An operating system is an interface between the hardware of a computer and the user (program or human) that facilitates the execution of the other programs and the access to hardware and software resources.
Two major design goals of an operating system are: OS Goals Two major design goals of an operating system are: Efficient use of hardware. Easy to use resources.
7.2 EVOLUTION Of OS
Batch operating systems(批处理操作系统): 1950s. job(作业) punched card(穿孔卡片) programmer(程序员) operator(操作员) Time-sharing systems(分时系统) 1960s ,multiprogramming(多道程序) time-sharing(分时) scheduling(调度) process(进程) Personal systems(个人系统) 1980s,single-user OS(DOS) Parallel systems(并行系统) multiple CPUs(多个CPU) Distributed Systems(分布式系统)
Batch operating systems programmer job operator punched card An IBM 704 mainframe 1950s. job(作业) punched card(穿孔卡片) operator(操作员) programmer(程序员)
Time-sharing systems 1960s , multiprogramming scheduling process An IBM System/360-20 (front panels removed), with IBM 2560 MFCM (Multi-Function Card Machine) programmer job 1960s , multiprogramming scheduling process A Televideo ASCII character mode terminal, using a microprocessor, manufactured around 1982 IBM 2311 disk drive.
7.3 COMPONENTS Of OS
Components of an operating system 用户界面 存储管理 设备管理 文件管理 进程管理
OS can be divided into two broad categories of memory management: 7.3.1 Memory Manager OS can be divided into two broad categories of memory management: Monoprogramming, and multiprogramming.
7.3.1 Memory Manager---Monoprogramming
7.3.1 Memory Manager --- Multiprogramming
Categories of multiprogramming
(1)Partitioning(Nonswapping)
(1)Partitioning(Nonswapping) 程序占用空间 分区大小 OS 4K 10K Holes(unused locations) 50K 100K 8K 10K
(2)Paging(Nonswapping)
(3)Demand Paging (swapping) The pages can be loaded into memory one by one, executed, and replaced by another page.
(4)Demand Segmentation (swapping) The modules of a program are loaded into memory, execute, and replaced by another module from the same or a different program.
(5)Demand Paging and Segmentation (swapping) Program is divided to modules. Memory is divide into frames, and module of a program is divided into pages. The pages of a module is loaded into memory one by one and executed.
Virtual Memory Demand paging and demand segmentation mean that part of the program is in main memory and part is on the disk when a program is being executed. One program Disk Physical memory
Virtual Memory 10prg. X 3MB/prg.=30MB 10prg. X 1MB/prg.=10MB
7.3.2 Process manager ---Program, Job, Process Program---It’s a nonactive set of instructions written by a programmer and stored on disk. Job---A program becomes a job from the moment it is selected for execution until it has finished running and becomes a program again. It may be in disk (be selected) or in memory (as a process). Process---It’s a program in execution. It’s a job that is residing in memory.
7.3.2 Process manager ---State Diagram
7.3.2 Process manager ---Job Scheduler
7.3.2 Process manager ---Process Scheduler
7.3.2 Process manager ---Queuing
Process Synchronization: Deadlock. Starvation. 7.3.2 Process manager ---Process Synchronization Process Synchronization: Deadlock. Starvation.
7.3.2 Process manager ---Deadlock
Figure 7-14 Deadlock on a bridge
Note: Deadlock occurs when the operating system does not put resource restrictions on processes.
1.mutual exclusion 2.resource holding 3.no preemption Deadlock condition There are four necessary conditions for deadlock: 1.mutual exclusion 2.resource holding 3.no preemption 4.circular waiting
7.3.2 Process manager ---Starvation
Figure 7-15.b Starvation
Figure 7-15.c Starvation
Figure 7-16 Dining philosophers
7.3.3 Device manager Device manager is responsible for the efficient use of I/O devices.
Device manager is responsible for the access to the files. 7.3.4 File manager Device manager is responsible for the access to the files. creation、deletion、modification、storage、archiving(存档)、backup
7.4 POPULAR OPERATING SYSTEMS
7.4 Popular operating systems---windows 2000 … (1) a complex menu-driven OS; (2)a full-fledged(成熟的 ) GUI; (3)uses virtual memory that allows multiprogramming; (4)integral networking capability.
7.4 Popular operating systems---Unix, Linux (1)portable (2)powerful set of utilities(command) (3)device independent multiprogramming virtual memory file and directory system Linux: It’s developed by Linux Torvalds in Finland, is based on Unix
方便其他软件的执行,它作为计算机系统的通用管理者,使系统有效地利用硬件和软件资源。 Summary 操作系统的作用是什么? 方便其他软件的执行,它作为计算机系统的通用管理者,使系统有效地利用硬件和软件资源。 操作系统的演化包括哪些内容? 批处理操作系统、分时操作系统、单用户操作系统、并行系统、分布式系统
在单道程序中,内存的大多数容量被一个程序独享 Summary 操作系统的功能? 内存管理、进程管理、设备管理、文件管理 在单道程序中,内存的大多数容量被一个程序独享 在多道程序中,多个程序同时在内存中 在分区调度中,内存被分为变长的分区,每个分区都装载一个程序
请求分段调度类似于分页调度,唯一不同的是分页调度中将程序分成大小相等的区域,而请求分段调度则是根据程序划分来分配合适的区域。 Summary 在分页调度中,内存被分成大小相等的部分,称为帧。程序被分成大小相等的部分,称为页。程序页面不需要连续,但所有的页都必须在内存中等待执行。 请求分页调度不要求所有的页必须在内存中 请求分段调度类似于分页调度,唯一不同的是分页调度中将程序分成大小相等的区域,而请求分段调度则是根据程序划分来分配合适的区域。
程序是一组由程序员编写的稳定指令集,并存储在磁盘或磁带上。 Summary 所有程序在内存中的大小总和就是虚拟内存。 程序是一组由程序员编写的稳定指令集,并存储在磁盘或磁带上。 作业是指被选择执行的程序。 进程是指驻留在内存中的作业。 状态图显示了程序、作业、进程的关系。作业可以处在保持、终止、就绪、运行或等待状态。进程只能处于后三者状态中的一种。
作业调度器将作业变成进程并且可以由进程返回成作业。 Summary 作业调度器将作业变成进程并且可以由进程返回成作业。 进程调度器把进程从一个状态转为另一个状态。 作业和进程在队列中等待。
饿死是指进程由于资源使用的限制太多而不能执行的情况。 Summary 死锁是指由于其他进程无限制地使用资源而导致进程无法执行的情况。 饿死是指进程由于资源使用的限制太多而不能执行的情况。 设备管理器控制对I/O设备的访问。 文件管理器控制对文件的访问。
用户界面是用来接受进程请求,并向操作系统的其他部分解释这些请求的软件。 Summary 用户界面是用来接受进程请求,并向操作系统的其他部分解释这些请求的软件。 Windows2000、UNIX、LINUX是三个流行的操作系统。
Key terms monoprogramming(单道程序):大多数内存专用于单一的程序,仅仅一小部分用来装载OS。 multiprogramming(多道程序):同一时刻可以装入多个程序并且能够同时执行这些程序。CPU轮流为它们服务。 Nonswapping(非交换技术) swapping(交换技术)
Key terms Nonswapping(非交换技术):程序在运行期间始终驻留在内存中。 Partitioning (分区调度):内存分成几个分区(不定长)。 Paging(分页调度):内存分成大小相等的帧,程序分成大小相等的页。页和帧的大小一般一样。
Key terms swapping(交换技术):在运行过程中,程序可以在内存和硬盘之间多次交换。 Demand paging(请求分页调度):程序所分成的页可以依次装入内存。 Demand segmentation(请求分段调度):程序分成段。 Virtual memory(虚拟内存)
Key terms Program(程序):由程序员编写的一组稳定的指令,存在硬盘(磁盘)上。 job(作业):从程序被选中执行,到其运行结束并再次成为程序的这段过程中,程序被称为作业。 每个作业都是程序,但并不是所有的程序都是作业。 process(进程):是执行中的程序。是驻留在内存中的作业。 每个进程都是作业,而每个作业未必是进程。
Key terms Process manager State Diagram(状态图):显示每个实体的不同状态。 Ready(就绪状态) Waiting(等待状态) Running(运行状态) Hold(保持) Terminated(终止)
Key terms Process manager schedulers(调度器) Job scheduler(作业调度器):将作业从保持状态(hold)转入就绪状态(ready),或从运行状态(running)转入终止状态(terminated)。 Process scheduler(进程调度器):将进程从一个状态装入另一个状态。
Key terms Process manager Queuing(队列):等待列表。 Job control block(作业控制块,JCB):保存作业信息。 Process control block(进程控制块,PCB) FIFO(First in,First out):先入先出。 SLF(Shortest length first) :最短长度优先。 The one with highest priority:最高优先级。
Key terms Process manager deadlock(死锁) mutual exclusion(互斥) Process Synchronization:进程同步。 deadlock(死锁) mutual exclusion(互斥) resource holding(资源占有) no preemption(不可抢占) circular waiting(循环等待) starvation(饿死)