操作系统 选择+简答

目录

C1

计算机组成部分

List and briefly define the four main elements of a computer.

A processor, which controls the operation of the computer and performs its data processing functions ;

a main memory, which stores both data and instructions;

I/O modules, which move data between the computer and its external environment;

and the system bus, which provides for communication among processors, main memory, and I/O modules.

列出并简要定义计算机的四个组成部分。

  • 处理器:控制计算机的操作,执行数据处理功能。
  • 内存:也叫主存储器,存储数据和程序。
  • 输入/输出模块:在计算机和外部环境之间移动数据。
  • 系统总线:在处理器、内存和输入输出间提供通信的设施。

处理器寄存器

Define the two main categories of processor registers.

User-visible registers: Enable the machine- or assembly-language programmer to minimize main memory references by optimizing register use. For high-level languages, an optimizing compiler will attempt to make intelligent choices of which variables to assign to registers and which to main memory locations. Some high-level languages, such as C, allow the programmer to suggest to the compiler which variables should be held in registers.

Control and status registers: Used by the processor to control the operation of the processor and by privileged, operating system routines to control the execution of programs.

定义处理器寄存器的两种主要类别。

  • 用户可见寄存器: 优先使用这些寄存器,可以使机器语言或者汇编语言的程序员减少对主存储器的访问次数。对高级语言而言,由优化编译器负责决定把哪些变量应该分配给主存储器,一些高级语言,如C语言,允许程序言建议编译器把哪些变量保存在寄存器中。

  • 控制和状态寄存器:用以控制处理器的操作,且主要被具有特权的操作系统例程使用,以控制程序的执行。

机器指令

In general terms, what are the four distinct actions that a machine instruction can specify?

These actions fall into four categories: Processor-memory: Data may be transferred from processor to memory or from memory to processor.

Processor-I/O: Data may be transferred to or from a peripheral device by transferring between the processor and an I/O module.

Data processing: The processor may perform some arithmetic or logic operation on data.

Control: An instruction may specify that the sequence of execution be altered.

一般而言,一条机器指令能指定的四种不同操作是什么?

  • 处理器-寄存器:数据可以从处理器传送到存储器,或者从存储器传送到处理器。
  • 处理器-I/O:通过处理器和I/O模块间的数据传送,数据可以输出到外部设备,或者从外部设备输入数据。
  • 数据处理:处理器可以执行很多关于数据的算术操作或者逻辑操作。
  • 控制:某些指令可以改变执行顺序。

中断定义

What is an interrupt?

An interrupt is a mechanism by which other modules (I/O, memory) may interrupt the normal sequencing of the processor.

什么是中断?

中断是指计算机运行过程中,出现某些意外情况需主机干预时,机器能自动停止正在运行的程序并转入处理新情况的程序,处理完毕后又返回原被暂停的程序继续运行。

中断处理方式

How are multiple interrupts dealt with?

Two approaches can be taken to dealing with multiple interrupts.

The first is to disable interrupts while an interrupt is being processed.

A second approach is to define priorities for interrupts and to allow an interrupt of higher priority to cause a lower-priority interrupt handler to be interrupted.

处理多中断有两种方法。

  • 第一种方法是当正在处理一个中断时,禁止再发生中断。
  • 第二种方法是定义中断优先级,允许高优先级的中断打断低优先级的中断处理器的运行。

内存层次

What characteristics distinguish the various elements of a memory hierarchy?

The three key characteristics of memory are cost, capacity, and access time.

内存层次各个元素间的特征是什么?

存储器的三个重要特性是:**价格,容量和访问时间。**并且各层次从上到下,每“位”价格降低,容量递增,访问时间递增。

高速缓存

What is cache memory?

Cache memory is a memory that is smaller and faster than main memory and that is interposed between the processor and main memory. The cache acts as a buffer for recently used memory locations.

什么是高速缓存?

高速缓冲存储器是比主存小而快的存储器,用以协调主存跟处理器,作为最近储存地址的缓冲区。

多处理器和多核系统的区别

What is the difference between a multiprocessor and a multicore system?

A multicore computer is a special case of a multiprocessor, in which all of the processors are on a single chip.

多处理器系统和多核系统的区别是什么?

  • 多处理器系统(Multiprocessor Systems)是指包含两台或多台功能相近的处理器,处理器之间彼此可以交换数据,所有处理器共享内存,I/O 设备,控制器,及外部设备,整个硬件系统由统一-的操作系统控制,在处理器和程序之间实现作业、任务、程序、数组极其元素各级的全面并行。

  • 多内核(multicore chips) 是指在一枚处理器(chip) 中集成两个或多个完整的计算引擎(内核)。

局部性原理

What is the distinction between spatial locality and temporal locality?

Spatial locality refers to the tendency of execution to involve a number of memory locations that are clustered. Temporal locality refers to the tendency for a processor to access memory locations that have been used recently.

空间局部性和时间局部性的区别是什么?

  • 空间局部性是指最近被访问的元素的周围在不久的将来可能会被访问。
  • 临时局部性(即时间局部性):是指最近被访问的元素在不久的将来可能会被再次访问。

局部性原理

In general, what are the strategies for exploiting spatial locality and temporal locality?

Spatial locality is generally exploited by using larger cache blocks and by incorporating prefetching mechanisms (fetching items of anticipated use) into the cache control logic. Temporal locality is exploited by keeping recently used instruction and data values in cache memory and by exploiting a cache hierarchy.

开发空间局部性和时间局部性的策略是什么?

  • 空间局部性的开发是利用更大的缓冲块并且在存储器控制逻辑中加入预处理机制。
  • 时间局部性的开发是利用在高速缓冲存储器中保留最近使用的指令及数据,并且定义缓冲存储的优先级。

选择1-2

1. (单选题)操作系统提供给程序员的接口是 [ ]

  • A. 进程
  • B. 系统调用
  • C. 库函数
  • D. B和C

我的答案: B正确答案: B

10

2. (单选题)分时系统中为了使多个用户能够同时与系统交互,最关键的问题是 [ ]

  • A. 计算机具有足够快的运算速度
  • B. 能快速进行内外存之间的信息交换
  • C. 系统能够及时接收多个用户的输入
  • D. 短时间内所有用户程序都能运行

我的答案: C正确答案: C

10

3. (单选题)系统功能调用是 [ ]

  • A. 用户编写的一个子程序
  • B. 高级语言中的库程序
  • C. 操作系统中的一条命令
  • D. 操作系统向用户程序提供的接口

我的答案: D正确答案: D

10

4. (单选题)从用户的观点看,操作系统是 [ ]

  • A. 用户与计算机之间的接口
  • B. 控制和管理计算机资源的软件
  • C. 合理地组织计算机工作流程的软件
  • D. 由若干层次的程序按一定的结构组成的有机体

我的答案: A正确答案: A

10

5. (单选题)在设计批处理系统时,首先要考虑的是 [ ]

  • A. 灵活性和可适应性
  • B. 交互性和响应时间
  • C. mg src=“http://p.ananas.chaoxing.com/star3/origin/b5bf31f5a8403f8b24d5849c6075fefb.png”>C.周转时间和系统吞吐量
  • D. 实时性和可靠性

我的答案: C正确答案: C

10

6. (单选题)批处理系统的主要缺点是 [ ]

  • A. CPU利用率低
  • B. 不能并发执行
  • C. 缺少交互性
  • D. 以上都不是

我的答案: C正确答案: C

10

7. (单选题)操作系统的基本类型主要有 [ ]

  • A. 批处理系统、分时系统及多任务系统
  • B. 实时操作系统、批处理操作系统及分时操作系统
  • C. 单用户系统、多用户系统及批处理系统
  • D. 实时系统、分时系统和多用户系统

我的答案: B正确答案: B

10

8. (单选题)设计实时操作系统时,首先应考虑系统的 [ ]

  • A. 可靠性和灵活性
  • B. 实时性和可靠性
  • C. 灵活性和可靠性
  • D. 优良性和分配性

我的答案: B正确答案: B

10

9. (单选题)多道程序设计是指 [ ]

  • A. 在实时系统中并发运行多个程序
  • B. 在分布系统中同一时刻运行多个程序
  • C. 在一台处理机上同一时刻运行多个程序
  • D. 在一台处理机上并发运行多个程序

我的答案: D正确答案: D

10

10. (单选题)能对外部输入的信息在规定时限内处理完毕并作出反应的操作系统称为 [ ]

  • A. 分时操作系统
  • B. 批处理操作系统
  • C. 实时操作系统
  • D. 多处理机操作系统

我的答案: C正确答案: C

C2

操作系统设计目标

What are three objectives of an OS design?

Convenience: An operating system makes a computer more convenient to use.

Efficiency: An operating system allows the computer system resources to be used in an efficient manner.

Ability to evolve: An operating system should be constructed in such a way as to permit the effective development, testing, and introduction of new system functions without interfering with service.

操作系统设计的三个目标是什么?

  • 方便:操作系统使计算机更易于使用。
  • 有效:操作系统允许以更有效的方式使用计算机系统资源。
  • 扩展的能力:在构造操作系统时,应该允许在不妨碍服务的前提下有效地开发、测试和引进新的系统功能。

操作系统内核

What is the kernel of an OS?

The kernel is a portion of the operating system that includes the most heavily used portions of software. Generally, the kernel is maintained permanently in main memory. The kernel runs in a privileged mode and responds to calls from processes and interrupts from devices.

什么是操作系统的内核?

操作系统内核是计算机上最低层的软件,提供计算机最核心的功能,比如:进程管理、内存管理、I/O管理、文件管理、网络管理等。

多道程序设计定义

What is multiprogramming?

Multiprogramming is a mode of operation that provides for the interleaved execution of two or more computer programs by a single processor.

什么是多道程序设计?

两个或两个以上程序在计算机系统中同处于开始到结束之间的状态,这就称为多道程序设计。也就是在计算机内存中同时存放几道相互独立的程序,使它们在管理程序控制之下,相互穿插的运行。多道程序技术运行的特征:多道、宏观上并行、微观上串行。

进程定义

What is a process?

A process is a program in execution.

A process is controlled and scheduled by the operating system.

什么是进程?

进程由三部分组成:

  • 一 段可执行的程序。
  • 程序所需要的相关数据(变量、工作空间、缓冲区等)。
  • 程序的执行上下文(也称进程状态)。

进程 上下文

How is the execution context of a process used by the OS?

The execution context, or process state, is the internal data by which the operating system is able to supervise and control the process.

操作系统是怎么使用进程上下文的?

执行上下文又称为进程状态,是操作系统用来管理和控制所需的内部数据。这种内部信息和进程是分开的,因为操作系统信息不允许被进程直接访问。上下文包括操作系统管理进程以及处理器正确执行进程所需要的所有信息,包括各种处理器寄存器的内容,如程序计数器和数据寄存器。它还包括操作系统使用的信息,如进程优先级以及进程是否在等待特定I/O事件的完成。

存储管理功能

List and briefly explain five storage management responsibilities of a typical OS.

Process isolation: The operating system must prevent independent processes from interfering with each other’s memory, both data and instructions.

Automatic allocation and management: Programs should be dynamically allocated across the memory hierarchy as required. Allocation should be transparent to the programmer. Thus, the programmer is relieved of concerns relating to memory limitations, and the operating system can achieve efficiency by assigning memory to jobs only as needed.

Support of modular programming: Programmers should be able to define program modules, and to create, destroy, and alter the size of modules dynamically.

Protection and access control: Sharing of memory, at any level of the memory hierarchy, creates the potential for one program to address the memory space of another. This is desirable when sharing is needed by particular applications. At other times, it threatens the integrity of programs and even of the operating system itself. The operating system must allow portions of memory to be accessible in various ways by various users.

列出并简要介绍操作系统的五种典型存储管理职责。

  • 进程隔离:操作系统必须保护独立的进程,防止互相干扰各自的存储空间,包括数据和指令。
  • 自动分配和管理:程序应该根据需要在存储层次间动态的分配,分配对程序员是透明的。因此,程序员无需关心与存储限制有关的问题,操作系统有效的实现分配问题,可以仅在需要时才给作业分配存储空间。
  • 支持模块化程序设计:程序员应该能够定义程序模块,并动态地创建、销毁模块,动态地改变模块大小。
  • 保护和访问控制:不论在存储层次中的哪一级,存储器的共享都会产生一个程序访问另一个程序存储空间的潜在可能性。当某个特定的应用程序需要共享时,这是可取的。但在其他时候,他可能会威胁到程序的完整性,甚至威胁到操作系统本身。
  • **长期存储:**许多应用程序需要在计算机关机后长时间的保存信息。

实地址和虚地址

Explain the distinction between a real address and a virtual address.

A virtual address refers to a memory location in virtual memory. That location is on disk and at some times in main memory.

A real address is an address in main memory.

解释实地址和虚地址的区别。

实地址:指的是主存中的地址,实际的主存储器的地址,对应主存空间,即物理空间。

虚地址:指的是存在于虚拟内存中的地址,它有时候在磁盘中,有时候在主存中。

时间片轮转

Describe the round-robin scheduling technique.

Round robin is a scheduling algorithm in which processes are activated in a fixed cyclic order; that is, all processes are in a circular queue. A process that cannot proceed because it is waiting for some event (e.g. termination of a child process or an input/output operation) returns control to the scheduler.

描述时间片轮询调度技术。

轮询调度是一种调度算法,所有的进程存放在一个环形队列中并按固定循序依次激活。因为等待一些事件(例如:等待一个子进程或者一个I/O操作)的发生而不能被处理的进程将控制权交给调度器。

单体内核和微内核

Explain the difference between a monolithic kernel and a microkernel.

A monolithic kernel is a large kernel containing virtually the complete operating system, including scheduling, file system, device drivers, and memory management. All the functional components of the kernel have access to all of its internal data structures and routines. Typically, a monolithic kernel is implemented as a single process, with all elements sharing the same address space.

A microkernel is a small privileged operating system core that provides process scheduling, memory management, and communication services and relies on other processes to perform some of the functions traditionally associated with the operating system kernel.

解释单体内核和微内核的区别。

  • 单体内核是一个提供操作系统应该提供的功能的大内核,包括调度、文件系统、网络、设备驱动程序、存储管理等。内核的所有功能成分都能够访问它的内部数据结构和程序。典型情况下,这个大内核是作为一个进程实现的,所有元素都共享相同的地址空间。
  • 微内核是一个小的有特权的操作系统内核,只提供包括进程调度、内存管理和进程间通信等基本功能,要依靠其他进程担当起和操作系统内核联系作用。

多线程

What is multithreading?

Multithreading is a technique in which a process, executing an application, is divided into threads that can run concurrently.

什么是多线程?

多线程技术是指把执行一个应用程序的进程划分为可以同时运行的多个线程。

对称多处理器

List the key design issues for an SMP operating system.

Simultaneous concurrent processes or threads;

scheduling;

synchronization;

memory management;

reliability and fault tolerance.

列出对称多处理器操作系统设计时要考虑的关键问题。

  • **并发进程或线程:**内核程序应可重入,以使多个处理器能同时执行同一段内核代码。当多个处理器执行内核的相同或不同部分时,为避免数据损坏和无效操作,需要妥善管理内核表和数据结构。
  • 调度:任何一个处理器都可以执行调度,这既增加了执行调度策略的复杂度,也增加了保证调度相关数据结构不被损坏的复杂度。如果使用的是内核级多线程方式,就存在将同一进程的多个线程同时调度在多个处理器上的可能性。
  • **同步:**因为可能会存在多个活跃进程访问共享地址空间或共享I/O资源的情况,因此必须认真考虑如何提供有效的同步机制这一问题。 同步用来实现互斥及事件排序。
  • 内存管理:多处理器上的内存管理要处理单处理器上内存管理涉及的所有问题。另外,操作系统还要充分利用硬件提供的并行性来实现最优性能。不同处理器上的分页机制必须进行调整,以实现多处理器共享页或段时的数据一致性, 执行页面置换。物理页的重用是我们关注的最大问题,即必须保证物理页在重新使用前不能访问到它以前的内容。
  • **可靠性和容错性:**出现处理器故障时,操作系统应能妥善地降低故障的影响。调度器和操作系统的其他部分必须能识别出发生故障的处理器,并重新组织管理表。

C3

进程抢占

What does it mean to preempt a process?

Process preemption occurs when an executing process is interrupted by the processor so that another process can be executed.

抢占一个进程是什么意思?

处理器为了执行另外的进程而终止当前正在执行的进程,这就叫进程抢占。

进程阻塞

Why does Figure 3.9b have two blocked states?

There are two independent concepts: whether a process is waiting on an event (blocked or not), and whether a process has been swapped out of main memory (suspended or not). To accommodate this 2 ×2 combination, we need two Ready states and two Blocked states.

为什么图3.9(b)中有两个阻塞态?

有两个独立的概念:进程是否在等待一个事件(阻塞与否)以及进程是否已经被患处主存(挂起与否)。为适应这种2*2的组合,需要两个阻塞态和两个挂起态。

中断和陷阱

What is the difference between an interrupt and a trap?

An interrupt is due to some sort of event that is external to and

中断和陷阱有什么区别?

  • 在程序运行过程中,系统出现了一个必须由CPU立即处理的情况,此时,CPU 暂时中止程序的执行转而处理这个新的情况的过程就叫做中断。中断与当前正在运行的进程无关的某些类型的外部事件相关,如完成一次I/O操作。
  • 陷阱指的是当异常或者中断发生时,处理器捕捉到一一个执行线程,并且将控制权转移到操作系统中某一个固定地址的机制。陷阱与当前正在运行的进程所产生的错误或异常条件相关,如非法的文件访问。

中断

Give three examples of an interrupt.

Clock interrupt, I/O interrupt, memory fault.

举出中断的三个例子。

时钟中断,I/O中断,内存失效。

信息表

For what types of entities does the OS maintain tables of information for management purposes?

The OS maintains tables for entities related to memory, I/O, files, and processes. See Table 3.10 for details.

对于哪类实体,操作系统为了管理它而维护其信息表?

内存,I/O、文件和进程。

进程状态

For the processing model of Figure 3.6, briefly define each state.

Running: The process that is currently being executed. Ready: A

简要定义图3.6所示进程模型中的每种状态。

  • 运行态:该进程正在执行。
  • 就绪态:进程做好了准备,只要有机会就会开始执行。
  • 阻塞态:进程在某些事件发生前不能执行,如I/O操作完成。
  • 新建态:刚刚创建的进程,操作系统还没有把它加入到可执行进程组中。
  • 退出态:操作系统从可执行进程中释放出的进程,或者是因为它自身停止了,或者是因为某种原因被取消。

进程创建

What common events lead to the creation of a process?

New batch job; interactive logon; created by OS to provide a service; spawned by existing process. See Table 3.1 for details.

通常哪些事件会导致创建一个进程?

  • 新的批处理作业;
  • 交互登录;
  • 操作系统因为提供一项服务而创建;
  • 由现有的进程派生。

进程挂起

List four characteristics of a suspended process.

  1. The process is not immediately available for execution.
  2. The process may or may not be waiting on an event. If it is, this blocked condition is independent of the suspend condition, and occurrence of the blocking event does not enable the process to be executed.
  3. The process was placed in a suspended state by an agent; either itself, a parent process, or the operating system, for the purpose of preventing its execution.
  4. The process may not be removed from this state until the agent explicitly orders the removal.

列出挂起状态进程的4个特点。

  1. 进程不能立即执行。
  2. 进程可能是或不是正在等待一个事件。如果是,阻塞条件不依赖于挂起条件,阻塞事件的发生不会使进程立即被执行。
  3. 为了阻止进程执行,可以通过代理把这个进程置于挂起态,代理可以是进程自己,也可以是父进程或操作系统。
  4. 除非代理显式地命令系统进行进行状态转换,否则进程无法从这个状态中转移。

进程创建

What are the steps performed by an OS to create a new process?

1.Assign a unique process identifier to the new process.

操作系统创建一个新进程所执行的步骤是什么?

  1. 给新进程分配一个唯一的进程标识号。
  2. 给进程分配空间。
  3. 初始化进程控制块。
  4. 设置正确的连接。
  5. 创建或扩充其他的数据结构。

指令跟踪

What is an instruction trace?

An instruction trace for a program is the sequence of instructions that execute for that process.

什么是指令跟踪?

指令跟踪是指为该进程而执行的指令序列。

进程控制块

List three general categories of information in a process control block.

Process identification, processor state information, and process control information.

列出进程控制块中的三类信息。

进程标识,处理器状态信息,进程控制信息。

两种模式

Why are two modes (user and kernel) needed?

The user mode has restrictions on the instructions that can be executed and the memory areas that can be accessed. This is to protect the operating system from damage or alteration.

In kernel mode, the operating system does not have these restrictions, so that it can perform its tasks.

为什么需要两种模式(用户模式和内核模式)?

用户模式下可以执行的指令和访问的内存区域都受到限制。这是为了防止操作系统受到破坏或者修改。

而在内核模式下则没有这些限制,从而使它能够完成其功能。

交换

What is swapping and what is its purpose?

Swapping involves moving part or all of a process from main memory to disk. When none of the processes in main memory is in the Ready state, the operating system swaps one of the blocked processes out onto disk into a suspend queue, so that another process may be brought into main memory to execute.

什么是交换,其目的是什么?

交换是指把主存中某个进程的一部分或者全部内容转移到磁盘。当主存中没有处于就绪态的进程时,操作系统就把一个阻塞的进程换出到磁盘中的挂起队列,从而使另一个进程可以进入主存执行。

选择3-4

1. (单选题)在引入线程概念之后,一个进程拥有线程的个数至少是 [ ]

  • A. 4个
  • B. 3个
  • C. 2个
  • D. 1个

我的答案: D

10

2. (单选题)正在执行的进程应终端的请求而暂停下来以便研究其运行情况(执行挂起进程原语),这时进程应转变为[ ]

  • A. 静止阻塞状态
  • B. 活动阻塞状态
  • C. 静止就绪状态
  • D. 活动就绪状态

我的答案: C

10

3. (单选题)通常用户进程被建立后, [ ]

  • A. 便一直存在于系统中,直到被操作人员撤消;
  • B. 随着进程运行的正常或不正常结束而撤消;
  • C. 随着时间片轮转而撤消与建立;
  • D. 随着进程的阻塞或唤醒而撤消与建立。

我的答案: B

10

4. (单选题)进程与程序的重要区别之一是 [ ]

  • A. 程序有状态而它没有
  • B. 它有状态而程序没有
  • C. 程序可占有资源而它不可
  • D. 它能占有资源而程序不能

我的答案: B

10

5. (单选题)进程从执行状态转变为就绪状态的原因是 [ ]

  • A. 进程被调度程序选中
  • B. 时间片到
  • C. 等待某一事件
  • D. 等待的事件发生

我的答案: B

10

6. (单选题)在Windows 2000中,能被切换成运行状态、占用处理器执行的线程状态是 [ ]

  • A. 备用
  • B. 就绪
  • C. 等待
  • D. 转换

我的答案: A

10

7. (单选题)处于静止阻塞状态的进程,在进程等待的事件出现后,应转变为 [ ]

  • A. 执行状态
  • B. 活动阻塞状态
  • C. 静止就绪状态
  • D. 活动就绪状态

我的答案: C

10

8. (单选题)下面对进程的描述中,错误的是 [ ]

  • A. 进程是动态的概念
  • B. 进程有生命期
  • C. 进程是指令的集合
  • D. 进程可以并发执行

我的答案: C

10

9. (单选题)操作系统中,可以并行运行、核心调度及资源分配的基本单位是 [ ]

  • A. 作业
  • B. 函数
  • C. 进程
  • D. 过程

我的答案: C

10

10. (单选题)Windows 2000 实现对线程的调度管理是采用 [ ]

  • A. 线程调度器、就绪队列表
  • B. 线程调度器、就绪队列表、就绪位图
  • C. 线程调度器、就绪队列表、就绪位图、空闲位图
  • D. 线程调度器就绪队列表、空闲位图

我的答案: C

C4

线程共享的资源

What resources are typically shared by all of the threads of a process?

Address space, file resources, execution privileges are examples.

哪些资源通常被一个进程中的所有线程共享?

进程中的所有线程共享该进程的状态和资源,例如地址空间,文件资源,执行特权等。

进程概念

What are the two separate and potentially independent characteristics embodied in the concept of process?

Resource ownership and scheduling/execution.

在进程概念中体现出的两个独立且无关的特点是什么?

  • 资源所有权: 进程包括存放进程映像的虚拟地址空间;回顾第3章的内容可知,进程映像是程序、数据、栈和进程控制块中定义的属性集。进程总具有对资源的控制权或所有权,这些资源包括内存、I/O通道、I/O设备和文件等。操作系统提供预防进程间发生不必要资源冲突的保护功能。
  • 调度/执行:进程执行时采用一个或多程序(见图1.5)的执行路径(轨迹),不同进程的执行过程会交替进行。因此,进程具有执行态(运行、就绪等)和分配给其的优先级,是可被操作系统调度和分派的实体。

线程切换

List reasons why a mode switch between threads may be cheaper than a mode switch between processes.

Less state information is involved.

请列出线程间的模式切换比进程间的模式切换开销更低的原因。

包含的状态信息更少。

线程

Give four general examples of the use of threads in a single-user multiprocessing system.

Foreground/background work;

asynchronous processing;

speedup of execution by parallel processing of data;

modular program structure.

给出在单用户多处理系统中使用线程的四个例子。

  • 前台和后台操作
  • 异步处理
  • 加速执行
  • 模块化程序结构。

用户级线程

List three advantages of ULTs over KLTs.

  1. Thread switching does not require kernel mode privileges because all of the thread management data structures are within the user address space of a single process. Therefore, the process does not switch to the kernel mode to do thread management. This saves the overhead of two mode switches (user to kernel; kernel back to user).

列出用户级线程优于内核级线程的三个优点。

  1. 由于所有线程管理数据结构都在一个进程的用户地址空间中,线程切换不需要内核级模式的特权,因此,进程不需要为了线程管理而切换到内核模式,这节省了在两种模式间进行切换(从用户模式到内核模式;从内核模式返回用户模式)的开销。

  2. 调用可以是应用程序专用的。一个应用程序可能倾向于就按单的轮询调度算法,而另一个应用程序可能倾向于基于优先级的调度算法。调度算法可以去适应应用程序,而不会扰乱底层的操作系统调度器。

  3. 用户级线程可以在任何操作系统中运行,不需要对底层内核进行修改以支持用户级线程。线程库是一组供所有应用程序共享的应用级软件包。

进程和线程控制块

Table 3.5 lists typical elements found in a process control block for an unthreaded OS. Of these, which should belong to a thread control block and which should belong to a process control block for a multithreaded system?

This will differ from system to system, but in general, resources are owned by the process and each thread has its own execution state. A few general comments about each category in Table 3.5:

表3.5列出了在一个没有线程的操作系统中进程控制块的基本元素。对于多线程系统,这些元素中哪些可能属于线程控制块,哪些可能属于进程控制块?

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-aWrtFn71-1683979954941)(D:#######\Typora\os\1843722-20210108164135430-1225869098.png)]

这对于不同的系统来说通常是不同的,但一般来说,进程是资源的所有者,而每个线程都有它自己的执行状态。关于表3.5中的每一项的一些结论如下:

  • 进程控制信息:调度和状态信息主要处于线程级;数据结构在两级都可出现;进程间通信和线程间通信都可以得到支持;特权在两级都可以存在;存储管理通常在进程级;资源信息通常也在进程级;
  • 进程标识:进程必须被标识,而进程中的每一个线程也必须有自己的ID。
  • 处理器状态信息:这些信息通常只与进程有关。

用户级线程

List two disadvantages of ULTs compared to KLTs.

  1. In a typical operating system, many system calls are blocking. Thus, when a ULT executes a system call, not only is that thread blocked, but also all of the threads within the process are blocked.
  2. In a pure ULT strategy, a multithreaded application cannot take advantage of multiprocessing. A kernel assigns one process to only one processor at a time. Therefore, only a single thread within a process can execute at a time.

列出用户级线程相较于内核级线程的两个缺点。

  • 在典型的操作系统中,许多系统调用都会引起阻塞。因此,当用户级线程执行一个系统调用时,不仅这个线程会被阻塞,进程中的所有线程都会被阻塞。
  • 在纯粹的用户级进程策略中,一个多线程应用程序不能利用多处理器技术。内核一次只把一个进程分配给一个处理器,因此一次进程中只能有一个线程可以执行。

套管

Define jacketing.

Jacketing converts a blocking system call into a nonblocking system call by using an application-level I/O routine which checks the status of the I/O device.

定义”套管“jacketing.
Jacketing通过调用一个应用级的I/O例程来检查I/O设备的状态,从而将一个产生阻塞的系统调用转化为一个不产生阻塞的系统调用。

C5

并发设计

List four design issues for which the concept of concurrency is relevant.

Communication among processes, sharing of and competing for resources, synchronization of the activities of multiple processes, and allocation of processor time to processes.

进程之间的通信、资源的共享和竞争、多个进程活动的同步以及为进程分配处理器时间。

列出与并发相关的4个设计问题。

  1. 操作系统必须能够跟踪不同的进程,这可使用进程控制块来实现。
  2. 操作系统必须为每个活动进程分配和释放各种资源。有时,多个进程想访问相同的资源。这些资源包括:
    • 处理器时间: 这是调度功能。
    • 存储器: 大多数操作系统使用虚存方案。
    • 文件。
    • I/O设备。
  3. 操作系统必须保护每个进程的数据和物理资源,避免其他进程的无意干扰,这涉及与存储器、文件和I/O设备相关的技术。
  4. 一个进程的功能和输出结果必须与执行速度无关(相对于其他并发进程的执行速度)。

并发上下文

What are three contexts in which concurrency arises?

Multiple applications, structured applications, operating-system

产生并发的三种上下文是什么?

  • **多应用程序:**多道程序设计技术允许在多个活动的应用程序间动态共享处理器时间。
  • **结构化应用程序:**作为模块化设计和结构化程序设计的扩展,一些应用程序可被有效地设计成一组并发进程。。
  • **操作系统结构:**同样的结构化程序设计优点适用于系统程序,且我们已知操作系统自身常常作为一组进程或线程实现。

并发进程执行

What is the basic requirement for the execution of concurrent processes?

The ability to enforce mutual exclusion.

执行并发进程的最基本要求是什么?

最基本要求是增加进程间的互斥能力。

进程交互

List three degrees of awareness between processes and briefly define each.

Processes unaware of each other: These are independent processes that are not intended to work together.

列出进程间的三种互相知道的程度,并简要给出各自的定义。

  • **进程之间相互不知道对方的存在:**这是一些独立的进程,它们不会一起工作。关于这种情况的最好例子是多个独立进程的多道程序设计,可以是批处理作业,也可以是交互式会话,或者是两者的混合。尽管这些进程不会一-起工作, 但操作系统需要知道它们对资源的竞争情况(competition)。例如,两个无关的应用程序可能都想访问同一个磁盘、文件或打印机。操作系统必须控制对它们的访问。
  • 进程间接知道对方的存在:这些进程并不需要知道对方的进程ID,但它们共享某些对象,如一个I/O缓冲区。这类进程在共享同-一个对象时会表现出合作行为(cooperation)。
  • **进程直接知道对方的存在:**这些进程可通过进程ID互相通信,以合作完成某些活动。同样,这类进程表现出合作行为。

进程竞争与合作

What is the distinction between competing processes and cooperating processes?

Competing processes need access to the same resource at the same time, such as a disk, file, or printer. Cooperating processes either share access to a common object, such as a memory buffer or are able to communicate with each other, and cooperate in the performance of some application or activity.

竞争进程和合作进程间有何区别?

竞争进程需要同时访问相同的资源,像磁盘,文件或打印机。合作进程要么共享访问一个共有的资源,像一个内存访问区,要么就与其他进程相互通信,在一些应用程序或活动上进行合作。

进程竞争控制

List the three control problems associated with competing processes and briefly define each.

Mutual exclusion: competing processes can only access a resource that both wish to access one at a time; mutual exclusion mechanisms must enforce this one-at-a-time policy. Deadlock: if competing processes need exclusive access to more than one resource then deadlock can occur if each processes gained control of one resource and is waiting for the other resource. Starvation: one of a set of competing processes may be indefinitely denied access to a needed resource because other members of the set are monopolizing that resource.

列出与竞争进程相关的三个控制问题,并简要给出各自的定义。

  • 互斥(mutual exclusion): 假设两个或更多的进程需要访问一个不可共享的资源,如打印机。在执行过程中,每个进程都给该I/O设备发命令,接收状态信息,发送数据和接收数据。我们把这类资源称为临界资源(critical resource),使用临界资源的那部分程序称为程序的临界区Ccritical section)。一次只允许有一 一个程序在临界区中,这一点非常重要。
  • **死锁(deadlock):**考虑两个进程P1和P2,以及两个资源R1和R2,假设每个进程为执行部分功能都需要访问这两个资源,那么就有可能出现下列情况:操作系统把R1分配给P2,把R2分配给P1,每个进程都在等待另一个资源,且在获得其他资源并完成功能前,谁都不会释放自己已拥有的资源,此时这两个进程就会发生死锁。
  • 饥饿(starvation):假设有三个进程(P1、P2 和P3),每个进程都周期性地访问资源R。考虑这种情况,即P1拥有资源,P2和P3都被延迟,等待这个资源。当P1退出其临界区时,P2和P3都允许访问R,假设操作系统把访问权授予P3,并在P3退出临界区之前P1又要访问该临界区,若在P3结束后操作系统又把访问权授予P1,且接下来把访问权轮流授予P1和P3,那么即使没有死锁,P2也可能被无限地拒绝访问资源。

进程互斥

List the requirements for mutual exclusion.

  1. Mutual exclusion must be enforced: only one process at a time is allowed into its critical section, among all processes that have critical sections for the same resource or shared object.

列出对互斥的要求。

要提供对互斥的支持,必须满足以下要求:

  1. 必须强制实施互斥:在与相同资源或共享对象的临界区有关的所有进程中,一次只允许一个进程进入临界区。
  2. 一个在非临界区停止的进程不能干涉其他进程。
  3. 绝不允许出现需要访问临界区的进程被无限延迟的情况,即不会死锁或饥饿。
  4. 没有进程在临界区中时,任何需要进入临界区的进程必须能够立即进入。
  5. 对相关进程的执行速度和处理器的数量没有任何要求和限制。
  6. 一个进程驻留在临界区中的时间必须是有限的。

信号量

What operations can be performed on a semaphore?

  1. A semaphore may be initialized to a nonnegative value.

在信号量上可以执行什么操作?

为达到预期效果,可把信号量视为-一个值为整数的变量,整数值上定义了三个操作:

  1. 一个信号量可以初始化成非负数。
  2. semWait 操作使信号量减1。若值变成负数,则阻塞执行semWait的进程,否则进程继续执行。
  3. semSignal 操作使信号量加1。若值小于等于零,则被semwait操作阻塞的进程解除阳塞。

一元信号量和二元信号量

What is the difference between binary and general semaphores?

A binary semaphore may only take on the values 0 and 1. A general semaphore may take on any integer value.

二进制信号量只能取0和1的值。通用信号量可以取任何整数值。

二元信号量和一般信号量有何区别?

  1. 二元信号量可以初始化为0或1。
  2. semWaitB 操作检查信号的值。若值为0,则进程执行semWaitB就会受阻。若值为1,则将值改为0,并继续执行该进程。
  3. semSignalB 操作检查是否有任何进程在该信号上受阻。若有进程受阻,则通过semWaitB操作,受阻的进程会被唤醒;若没有进程受阻,则值设置为1。

信号量和弱信号量

What is the difference between strong and weak semaphores?

A strong semaphore requires that processes that are blocked on that semaphore are unblocked using a first-in-first-out policy. A weak semaphore does not dictate the order in which blocked processes are unblocked.

强信号量和弱信号量有何区别?

强信号量要求在信号量上等待的进程按照先进先出的规则从队列中移出。弱信号量没有此规则。

管程

What is a monitor?

A monitor is a programming language construct providing abstract data types and mutually exclusive access to a set of procedures

什么是管程?

管程是由一个或多个过程,一个初始化序列和局部数据组成的软件模块,其主要特定如下:

  • 局部数据变量只能被管程的过程访问,任何外部过程都不能访问。
  • 一个进程通过调用管程的一个过程进入管程。
  • 在任何时候,只能有一个进程在管程中执行,调用管程的任何其他进程都被阻塞,以等待管程可用。

选择5-6

1. (单选题)设有5个进程共享一个互斥段,如果允许有3个进程同时进入互斥段,则所采用的互斥信号量的初值应是 [ ]

  • A. 5
  • B. 3
  • C. 1
  • D. 0

我的答案: B正确答案: B

10

2. (单选题)下面临界区概念论述正确的是 [ ]

  • A. 临界区是指进程中用于实现进程互斥的那段程序代码
  • B. 临界区是指进程中用于实现进程同步的那段程序代码
  • C. 临界区是指进程中用于实现进程通信的那段程序代码
  • D. 临界区是指进程中用于访问临界资源的那段程序代码

我的答案: D正确答案: D

10

3. (单选题)死锁与安全状态的关系是 [ ]

  • A. 死锁状态有可能是安全状态
  • B. 安全状态有可能成为死锁状态
  • C. 不安全状态就是死锁状态
  • D. 死锁状态一定是不安全状态

我的答案: D正确答案: D

10

4. (单选题)死锁预防是保证系统不进入死锁状态的静态策略,其解决办法是破坏产生死锁的四个必要条件之一。下列方法中破坏了“循环等待”条件的是 [ ]

  • A. 银行家算法
  • B. 一次性分配策略
  • C. 剥夺资源法
  • D. 资源有序分配策略

我的答案: D正确答案: D

10

5. (单选题)系统中有n(n>2)个进程,并且当前没有执行进程调度程序,不可能发生的是[ ]

  • A. 有一个运行进程,没有就绪进程,剩下的n-1个进程处于等待状态
  • B. 有一个运行进程和n-1个就绪进程,但没有进程处于等待状态
  • C. 有一个运行进程和1个就绪进程,剩下的n-2个进程处于等待状态
  • D. 没有运行进程但有2个就绪进程,剩下的n-2个进程处于等待状态

我的答案: D正确答案: D

10

6. (单选题)设m为同类资源数,n为系统中并发进程数。当n个进程共享m个互斥资源时,每个进程的最大需求是w;则下列情况会出现系统死锁的是 [ ]

  • A. m=2,n=1,w=2
  • B. m=2,n=2,w=1
  • C. m=4,n=3,w=2
  • D. m=4,n=2,w=3

我的答案: D正确答案: D

10

7. (单选题)对两个并发进程,其互斥信号量为mutex;若mutex=0,则表明 [ ]

  • A. 没有进程进入临界区
  • B. 有一个进程进入临界区但没进程处于阻塞状态
  • C. 一个进程进入临界区而另一个进程正处于等待进入临界区状态
  • D. 有两个进程进入临界区

我的答案: B正确答案: B

10

8. (单选题)在消息缓冲通信方式中,临界资源为 [ ]

  • A. 发送进程
  • B. 消息队列
  • C. 接收进程
  • D. 信箱

我的答案: B正确答案: B

10

9. (单选题)在操作系统中,P、V操作是一种 [ ]

  • A. 机器指令
  • B. 系统调用命令
  • C. 作业控制命令
  • D. 低级进程通信原语

我的答案: D正确答案: D

10

10. (单选题)我们把在一段时间内,只允许一个进程访问的资源,称为临界资源,因此,我们可以得出下列论述,正确的论述是 [ ]

  • A. 对临界资源是不能实现资源共享的。
  • B. 对临界资源,应采取互斥访问方式,来实现共享。
  • C. 为临界资源配上相应的设备控制块后,便能被共享。
  • D. 对临界资源应采取同时访问方式,来实现共享。

我的答案: B正确答案: B

10

C6

可重用和可消耗资源

Give examples of reusable and consumable resources.

Examples of reusable resources are processors, I/O channels, main and secondary memory, devices, and data structures such as files, databases, and semaphores. Examples of consumable resources are interrupts, signals, messages, and information in I/O buffers.

给出可重用资源和可消耗资源的例子。

  • 可重用资源是指一次仅供-一个进程安全使用且不因使用而耗尽的资源。进程得到资源单元并使用后,会释放这些单元供其他进程再次使用。可重用资源的例子包括处理器、I/O 通道、内存和外存、设备,以及诸如文件、数据库和信号量之类的数据结构。
  • 可消耗资源是指可被创建(生产)和销毁(消耗)的资源。某种类型可消耗资源的数量通常没有限制,无阻塞生产进程可以创建任意数量的这类资源。消费进程得到-一个资源时,该资源就不再存在。可消耗资源的例子有中断、信号、消息和I/O缓冲区中的信息。

死锁必要条件

What are the three conditions that must be present for deadlock to be possible?

Mutual exclusion. Only one process may use a resource at a time.

产生死锁的三个必要条件是什么?

  • 互斥。一次只有一个进程可以使用一个资源。其他进程不能访问已分配给其他进程的资源。
  • 占有且等待。当一个进程等待其他进程时,继续占有已分配的资源。
  • 不可抢占。不能强行抢占进程已占有的资源。

死锁4个条件

What are the four conditions that create deadlock?

The above three conditions, plus: Circular wait. A closed chain of processes exists, such that each process holds at least one resource needed by the next process in the chain.

产生死锁的 4个条件是什么?

  1. 互斥条件:资源是独占的且排他使用,进程互斥使用资源,即任意时刻一个资源只能给一个进程使用,其他进程若申请一个资源,而该资源被另一进程占有时,则申请者等待直到资源被占有者释放。
  2. 不可剥夺条件:进程所获得的资源在未使用完毕之前,不被其他进程强行剥夺,而只能由获得该资源的进程资源释放。
  3. 请求和保持条件:进程每次申请它所需要的一部分资源,在申请新的资源的同时,继续占用已分配到的资源。
  4. 循环等待条件:在发生死锁时必然存在一个进程等待队列{P1,P2,…,Pn},其中P1等待P2占有的资源,P2等待P3占有的资源,…,Pn等待P1占有的资源,形成一个进程等待环路,环路中每一个进程所占有的资源同时被另一个申请,也就是前一个进程占有后一个进程所深情地资源。

死锁预防

How can the hold-and-wait condition be prevented?

The hold-and-wait condition can be prevented by requiring that a process request all of its required resources at one time, and blocking the process until all requests can be granted simultaneously.

如何防止占有且等待条件?

为预防占有且等待的条件,可以要求进程一次性地请求所有 需要的资源,并阻塞这个进程直到所有请求都同时满足。这种方法有两个方面的低效性。首先,一个进程可能被阻塞很长时间,以等待满足其所有的资源请求。而实际上,只要有一部分资源, 它就可以继续执行。其次,分配给一个进程的资源可能会在相当长的一段时间不会被该进程使用,且不能被其他进程使用。另一个问题是一个进程可能事先并不知道它所需要的所有资源。

死锁预防

List two ways in which the no-preemption condition can be prevented.

First, if a process holding certain resources is denied a further request, that process must release its original resources and, if necessary, request them again together with the additional resource. Alternatively, if a process requests a resource that is currently held by another process, the operating system may preempt the second process and require it to release its resources.

给出防止不可抢占条件的两种方法。

  1. 占有某些资源的一个进程进一步申请资源时若被拒绝,则该进程必须释放其最初占有的资源,必要时可再次申请这些资源和其他资源。
  2. 一个进程请求当前被另一个进程占有的一个资源时,操作系统可以抢占另一个进程,要求它释放资源。(只有在任意两个进程的优先级都不同时,这种方案才能预防死锁)。

死锁预防

How can the circular-wait condition be prevented?

The circular-wait condition can be prevented by defining a linear ordering of resource types. If a process has been allocated resources of type R, then it may subsequently request only those resources of types following R in the ordering.

如何防止循环等待条件?

循环等待条件可通过定义资源类型的线性顺序来预防。若一 个进程已分配了R类型的资源,则其接下来求的资源只能是那些排在R类型之后的资源。为证明这种策略的正确性,我们给每种资源类型指定一个下标。 当i<j时,资源R排在资源R,前面。现在假设两个进程A和B死锁,原因是A获得R并请求R,而B获得R,并请求R,那么这个条件不可能,因为这意味着i<j且j<i。

死锁处理

What is the difference among deadlock avoidance, detection, and prevention?

Deadlock prevention constrains resource requests to prevent at least one of the four conditions of deadlock; this is either done indirectly, by preventing one of the three necessary policy conditions (mutual exclusion, hold and wait, no preemption), or directly, by preventing circular wait.

死锁避免、 检测和预防之间的区别是什么?

处理死锁通常有三种方法:预防、检测和避免。

死锁预防通过确保不满足死锁的一个必要条件来避免发生死锁。

操作系统总是同意资源请求时,需要进行死锁检测。操作系统必须周期性地检查死锁,并采取行动打破死锁。

死锁避免涉及分析新的资源请求,以确定它是否会导致死锁,且仅当不可能发生死锁时才同意该请求。

C7

共享

What are some reasons to allow two or more processes to all have access to a particular region of memory?

If a number of processes are executing the same program, it is advantageous to allow each process to access the same copy of the program rather than have its own separate copy. Also, processes that are cooperating on some task may need to share access to the same data structure.

允许两个或多 个进程访问内存某一特定区域的原因是什么?

任何保护机制都必须具有一定的灵活性,以允许多个进程访问内存的同一部分。例如,多个进程正在执行同一个程序时,允许每个进程访问该程序的同一个副本,要比让每个进程有自己单独的副本更有优势。合作完成同一个任务的进程可能需要共享访问相同的数据结构。因此,内存管理系统在不损害基本保护的前提下,必允许对内存共享区域进行受控访问。我们将会看到用于支持重定位的机制也支持共享。

固定分区

In a fixed-partitioning scheme, what are the advantages of using unequal-size

By using unequal-size fixed partitions: 1. It is possible to provide one or

在固定分区方案中,使用大小不等的分区有何好处?

可缓解因程序太大而无法放到固定大小的分区和因程序太小产生大量内部碎片的问题。

页和段

What is the difference between a page and a segment?

An alternative way in which the user program can be subdivided is segmentation. In this case, the program and its associated data are divided into a number of segments. It is not required that all segments of all programs be of the same length, although there is a maximum segment length.

页和段有何区别?

页大小相等,段可以大小不等;分页对程序员来说是透明的,而分段通常是可见的。

页和段

Why is it not possible to enforce memory protection at compile time?

Because the location of a program in main memory is unpredictable, it is impossible to check absolute addresses at compile time to assure protection. Furthermore, most programming languages allow the dynamic calculation of addresses at run time, for example by computing an array subscript or a pointer into a data structure. Hence all memory references generated by a process must be checked at run time to ensure that they refer only to the memory space allocated to that

为何不可能在编译时实施内存保护?

由于程序在内存中的位置不可预测,因而在编译时不可能检查绝对地址来确保保护。此外,大多数程序设计语言允许在运行时进行地址的动态计算。因此必须在运行时检查进程产生的所有内存访问。

逻辑地址、相对地址和物理地址

What are the distinctions among logical, relative, and physical addresses?

A logical address is a reference to a memory location independent of the current assignment of data to memory; a translation must be made to a physical address before the memory access can be achieved. A relative address is a particular example of logical address, in which the address is expressed as a location relative to some known point, usually the beginning of the program. A physical address, or absolute address, is an actual location in main memory.

逻辑地址、相对地址和物理地址有何区别?

  • 逻辑地址(logical address) 是指与当前数据在内存中的物理分配地址无关的访问地址,在执行对内存的访问之前必须把它转换为物理地址。
  • 相对地址(relative address) 是逻辑地址的一个特例,它是相对于某些已知点(通常是程序的开始处)的存储单元。
  • 物理地址( physical address) 或绝对地址是数据在内存中的实际位置。

碎片

What is the difference between internal and external fragmentation?

Internal fragmentation refers to the wasted space internal to a partition due to the fact that the block of data loaded is smaller than the partition. External fragmentation is a phenomenon associated with dynamic partitioning, and refers to the fact that a large number of small areas of main memory external to any partition accumulates.

内部碎片和外部碎片有何区别?

  • 内部碎片:由于装入的数据块小于分区大小,因而导致分区内部存在空间浪费,这种现象称为内部碎片( internal fragmentation)。
  • 外部碎片:随着时间的推移,内存中形成了越来越多的碎片,内存的利用率随之下降。这种现象称为外部碎片(external fragmentation),指在所有分区外的存储空间变成了越来越多的碎片,这与前面所讲的内部碎片正好对应。

页和页框

What is the difference between a page and a frame?

In a paging system, programs and data stored on disk or divided into equal, fixed-sized blocks called pages, and main memory is divided into blocks of the same size called frames. Exactly one page can fit in one frame.

页和页框有何区别?

  • 页(page):一页指一系列的线性地址和包含于其中的数据。
  • 页框(pageframe):分页单元认为所有的RAM被分成了固定长度的页框每个页框可以包含一页,也就是说一个页框的长度和一个页的长度是一样的。页框是内存的一部分,是一个实际的存储区域。页只是一组数据块,可以存放在任何页框中。
    也就是说页对应的是线性(虚拟)地址的东西,而页框对应的是物理地址,是实际的存储区域。

内存管理需求

What requirements is memory management intended to satisfy?

Relocation, protection, sharing, logical organization, physical organization.

内存管理需要满足哪些需求?

  • 重定位
  • 保护
  • 共享
  • 逻辑组织
  • 物理组织

重定位

Why is the capability to relocate processes desirable?

Typically, it is not possible for the programmer to know in advance which other programs will be resident in main memory at the time of execution of his or her program. In addition, we would like to be able to swap active processes in and out of main memory to maximize processor utilization by providing a large pool of ready processes to execute. In both these cases, the specific location of the process in main memory is unpredictable.

为何需要重定位进程的能力?

在多道程序设计系统中,可用的内存空间通常被多个进程共享。通常情况下,程序员事先并不知道在某个程序执行期间会有其他哪些程序驻留在内存中。此外,我们还希望提供一个巨大的就绪进程池,以便把活动进程换入或换出内存,进而使处理器的利用率最大化。程序换出到磁盘中后,下次换入时要放到与换出前相同的内存区域会很困难。相反,我们需要把进程重定位(relocate) 到内存的不同区域。

选择7-8

1. (单选题)最佳适应算法的空白区是 [ ]

  • A. 按大小递减顺序排列
  • B. 按大小递增顺序排列
  • C. 按地址由小到大排列
  • D. 按地址由大到小排列

我的答案: B

10

2. (单选题)采用段式存储管理的系统中,若地址用24位表示,其中8位表示段号,则允许每段的最大长度是 [ ]

  • A. 2 24
  • B. 2 16
  • C. 2 8
  • D. 2 32

我的答案: B

10

3. (单选题)具有虚拟存储功能的管理方法包括 [ ]

  • A. 可变分区存储管理
  • B. 页式存储管理
  • C. 段式存储管理
  • D. 段页式管理

我的答案: D

10

4. (单选题)在可变式分区分配方案中,将空白区在空白区表中按地址递增次序排列是 [ ]

  • A. 最佳适应算法
  • B. 最差适应算法
  • C. 最先适应算法
  • D. 最迟适应算法

我的答案: C

10

5. (单选题)某虚拟存储器系统采用页式内存管理,使用LRU页面替换算法,考虑下面的页面访问地址流(每次访问在一个时间单位中完成):8 1 7 8 2 7 2 1 8 3 8 2 1 3 1 7 1 3 7内存容量为4个页面,开始时是空的,则页面失效次数是 [ ]

  • A. 4
  • B. 5
  • C. 6
  • D. 7
  • E.
  • F.

我的答案: C

10

6. (单选题)页式虚拟存储管理的主要特点是 [ ]

  • A. 不要求将作业装入到主存的连续区域
  • B. 不要求将作业同时全部装入到主存的连续区域
  • C. 不要求进行缺页中断处理
  • D. 不要求继续页面置换

我的答案: B

10

7. (单选题)下面关于虚拟存储器的论述中,正确的是 [ ]

  • A. 在段页式系统中以段为单位管理用户的逻辑空间,以页为单位管理内存的物理空间; 有了虚拟存储器才允许用户使用比内存更大的地址空间
  • B. 为了提高请求分页系统中内存的利用率允许用户使用不同大小的页面
  • C. 为了能让更多的作业同时运行,通常只装入10%~30%的作业即启动运行
  • D. 最佳适应算法是实现虚拟存储器的常用算法

我的答案: A

10

8. (单选题)在下列存储管理方案中,不适应于多道程序设计的是 [ ]

  • A. 单一连续区分配
  • B. 固定式分区分配
  • C. 可变式分区分配
  • D. 段页式存储管理

我的答案: A

10

9. (单选题)不会产生内部碎片的是 [ ]

  • A. 分页式存储管理
  • B. 分段式存储管理
  • C. 固定分区式存储管理
  • D. 段页式存储管理

我的答案: B

10

10. (单选题)把作业地址空间中使用的逻辑地址变成内存中物理地址称为 [ ]

  • A. 加载
  • B. 重定位
  • C. 物理化
  • D. 逻辑化

我的答案: B

10

C8

页面读取策略

Briefly define the alternative page fetch policies.

With demand paging, a page is brought into main memory only when a reference is made to a location on that page. With prepaging, pages other than the one demanded by a page fault are brought in.

简单定义两种可供选择的页面读取策略。

  • 请求分页,只有当访问到某页中的一个单元时才将该页取入内存。若内存管理的其他策略比较合适,将发生下述情况:当一个进程首次启动时,会在一段时间出现大量的缺页中断:取入越来越多的页后,局部性原理表明大多数将来访问的页都是最近读取的页。因此,在一段时间后错误会逐渐减少,缺页中断的数量会降到很低。

  • 预先分页,读取的页并不是缺页中断请求的页。预先分页利用了大多数辅存设备(如磁盘)的特性,这些设备有寻道时间和合理的延迟。若一 个进程的页连续存储在辅存中,则一次读取许多连续的页要比隔一段时间读取一 页有效。 当然,若大多数额外读取的页未引用到,则这个策略是低效的。

页表项

What elements are typically found in a page table entry? Briefly define each element.

the sequential number that identifies a page in main memory; present bit: indicates whether this page is currently in main memory;

哪些元素是页表项中能找到的典型元素?简单定义每个元素。

  • 页号: 虚拟地址的页号部分。
  • 进程标志符:使用该页的进程。页号和进程标志符共同标志-个特定进程的虚拟地址空间的一页。
  • 控制位: 该域包含一些标记, 比如有效、访问和修改,以及保护和锁定信息。
  • 链指针: 若某项没有链项,则该域为空(或用一个单独的位来表示)。否则,该域包含链中下一项的索引值(0~2^m -1之间的数字)。

页面置换算法

What is the relationship between FIFO and clock page replacement algorithms?

The clock policy is similar to FIFO, except that in the clock policy, any frame with a use bit of 1 is passed over by the algorithm.

FIFO 和时钟页面置换算法有何联系?

最简单的时钟策略需要给每个页框关联一个称为使用位的附加位。FIFO和时钟页面置换算法都会扫描缓冲区,FIFO直接置换出最老的页,而在时钟策略中会跳过使用位为1的页框。

驻留集和页面置换

What is the difference between resident set management and page replacement policy?

Resident set management deals with the following two issues:

(1) how many page frames are to be allocated to each active process;

(2) whether the set of pages to be considered for replacement should be limited to those of the process that caused the page fault or encompass all the page frames in main memory. Page replacement policy deals with the following issue: among the set of pages considered, which particular page should be selected for replacement.

驻留集管理和页面置换策略有何区别?

驻留集管理的概念为:

(1)给每个活动进程分配多少页框。

(2)计划置换的页集是局限于那些缺页中断的进程,还是局限于所有页框都在内存中的进程。
置换策略的概念为:在计划置换的页集中,选择换出哪一页。

全局置换和固定分配

Why is it not possible to combine a global replacement policy and a fixed allocation policy?

Because a fixed allocation policy requires that the number of frames allocated to a process is fixed, when it comes time to bring in a new page for a process, one of the resident pages for that process must be swapped out (to maintain the number of frames allocated at the same amount), which is a local replacement policy.

为什么不能把全局置换策略和固定分配策略组合起来?

因为固定分配策略下,驻留集的大小是固定不变的,从内存中移出的一页必须由同一个进程的另一页置换。

页缓冲

What is accomplished by page buffering?

(1) If a page is taken out of a resident set but is soon needed, it is still

页缓冲实现什么功能?

为提升性能,不丢弃置换出的页,被置换出的页任然驻留在内存中。因此,若进程访问该页,则可迅速返回该进程的驻留集,且代价很小。

驻留集和工作集

What is the difference between a resident set and a working set?

The resident set of a process is the current number of pages of that process in main memory.

The working set of a process is the number of pages of that process that have been referenced recently.

驻留集和工作集有何区别?

驻留集表示进程在内存中的页集,工作集表示进程在过去的一段时间中被访问到的页集。

转换检测缓冲区

What is the purpose of a translation lookaside buffer?

The TLB is a cache that contains those page table entries that have been most recently used. Its purpose is to avoid, most of the time, having to go to disk to retrieve a page table entry.

转换检测缓冲区的目的是什么?

原则上,每次虚存访问都可能会引起两次物理内存访问:一次取相应的页表项,另一次取需要的数据。因此,简单的虚拟内存方案会导致内存访问时间加倍。为克服这个问题,大多数虚拟内存方案都为页表项使用了一个特殊的高速缓存,通常称为转换检测缓冲区(TranslationLookaside Buffer, TLB)。

局部性原理

Why is the principle of locality crucial to the use of virtual memory?

Algorithms can be designed to exploit the principle of locality to avoid thrashing. In general, the principle of locality allows the algorithm to predict which resident pages are least likely to be referenced in the near future and are therefore good candidates for being swapped out.

为何在使用虚拟内存时,局部性原理至关重要?

局部性原理描述了一个进程中程序和数据引用的集簇倾向。因此,假设在很短的时间内仅需要进程的一部分块是合理的。同时,还可以对将来可能会访问的块进行猜测,从而避免系统抖动。局部性原理表明虚拟内存方案是可行的。

抖动

Explain thrashing.

Thrashing is a phenomenon in virtual memory schemes, in which the processor spends most of its time swapping pieces rather than executing instructions.

什么是抖动?

当操作系统读取一块内存时,它必须把另一块换出。 如果一块正好在将要用到之前换出,操作系统就不得不很快地把它取回。这类操作通常会导致一种称为系统抖动(thrashing)的情况。这样会使处理器的大部分时间都用于交换块而非执行指令。

简单分页和虚拟分页

What is the difference between simple paging and virtual memory paging?

Simple paging: all the pages of a process must be in main memory for process to run, unless overlays are used. Virtual memory paging: not all pages of a process need be in main memory frames for the process to run.; pages may be read in as needed

简单分页与虚拟内存分页有何区别?

进程运行时,简单分页的所有页必须都在内存中,除非使用了覆盖技术,虚存分页并非所有页都须在内存页框中,仅在需要时才读入页,把一页读入内存可能需要把另一页写出到磁盘。

C9

Briefly describe the three types of processor scheduling.

简要描述三种类型的处理器调度。

  • 长程调度:决定加入待执行进程池。

  • 中称调度:决定加入部分或全部位于内存中的进程集合。

  • 短程调度: 决定可用I/O设备处理哪个进程挂起的I/O请求。

What is usually the critical performance requirement in an interactive operating system?

在交互式操作系统中,通常最重要的性能要求是什么?

响应时间

What is the difference between turnaround time and response time?

周转时间和响应时间有何区别?

周转时间指一个进程从提交到完成之间的时间间隔,包括实际执行时间和等待资源(包括处理器资源)的时间;

响应时间指从提交一个请求到开始接收响应之间的时间间隔。

For process scheduling, does a low-priority value represent a low priority or a high priority?

对于进程调度, 较小的优先级值是表示较低的优先级还是表示较高的优先级?

  • 对于UNIX和许多其他操作系统中,优先级数值越,表示的进程优先级越
  • 某些系统如Windows的用法正好相反,即大数值表示高优先级。

What is the difference between preemptive and nonpreemptive scheduling?

抢占式调度和非抢占式调度有何区别?

  • 非抢占:在这种情况下,一旦进程处于运行状态,就会不断执行直到终止,进程要么因为等待I/O,要么因为请求某些操作系统服务而阻塞自己。
  • 抢占:当前正运行进程可能被操作系统中断,并转换为就绪态。一个新进程到达时,或中断发生后把一个阻塞态进程置为就绪态时,或出现周期性的时间中断时,需要进行抢占决策。

Briefly define FCFS scheduling.

简单定义FCFS调度。

每个进程就绪后,会加入就绪队列。当前正运行的进程停止执行时,选择就绪队列中存在时间最长的进程运行。

Briefly define round-robin scheduling.

简单定义轮转调度。

这种算法周期性地产生时钟中断,出现中断时,当前正运行的进程会放置到就绪队列中,然后基于FCFS策略选择下一个就绪作业运行。

Briefly define shortest-process-next scheduling.

简单定义最短进程优先调度。

这是一个非抢占策略,其原则是下次选择预计处理时间最短的进程。

Briefly define shortest-remaining-time scheduling.

简单定义最短剩余时间调度。

最短剩余时间是在SPN中增加了抢占机制的策略。在这种情况下,调度程序总是选择预期剩余时间最短的进程。

Briefly define highest-response-ratio-next scheduling.

简单定义最高响应比优先调度。

当前进程完成或被阻塞时,选择R值最大的就绪进程。调度决策基于对归一化周转时间的估计。

Briefly define feedback scheduling.

简单定义反馈调度。

调度基于抢占原则并使用动态优先级机制。建立一组调度队列,基于每个进程的执行历史和其他一 些规则,把它们分配到各个队列中。

选择9&11

1. (单选题) 作业周转时间为[ ]

  • A. 作业开始时间-作业提交时间
  • B. 作业等待时间+作业执行时间
  • C. 作业等待时间
  • D. 作业执行时间

B

2. (单选题) 设有4个作业同时到达,每个作业的执行时间均为2小时,它们在一台处理机上按单道方式运行,则平均周转时间为 [ ]

  • A. 1小时
  • B. 5小时
  • C. 2.5小时
  • D. 8小时

B

3. (单选题) 现有3个同时到达的作业J1、J2和J3,它们的执行时间分别是T1、T2和T3,且T1<T2<T3。系统按单道方式运行且采用短作业优先算法,则平均周转时间是 [ ]

  • A. T1+T2+T3
  • B. (T1+T2+T3 )/3
  • C. (3T1+2T2+T3)/3
  • D. (T1+2T2+3T3 )/3

C

4. (单选题) 在现代操作系统中必不可少的调度是 [ ]

  • A. 高级调度
  • B. 中级调度
  • C. 作业调度
  • D. 进程(线程)调度

D

5. (单选题) 进程调度的对象和任务分别是 [ ]

  • A. 作业,从就绪队列中按一定的调度策略选择一个进程占用CPU
  • B. 进程,从就绪队列中按一定的调度策略选择一个进程占用CPU
  • C. 进程,从后备作业队列中按一定的调度策略选择一个作业占用CPU
  • D. 作业,从后备作业队列中按一定的调度策略选择一个作业占用CPU

B

6. (单选题) 一作业8:00到达系统,估计运行时间为1小时。若10:00开始执行该作业,其响应比是[ ]

  • A. 2
  • B. 1
  • C. 3
  • D. 0.5

C

7. (单选题) 哪一个说法对剥夺式系统来讲结论正确 [ ]

  • A. 若系统采用轮转法调度进程,则系统采用的是剥夺式调度
  • B. 若现行进程要等待某一事件时引起调度,则该系统是剥夺式调度
  • C. 实时系统通常采用剥夺式调度
  • D. 在剥夺式系统中,进程的周转时间较之非剥夺式系统可预见

A

8. (单选题) 既考虑作业等待时间又考虑作业执行时间的调度算法是 [ ]

  • A. 响应比高者优先
  • B. 短作业优先
  • C. 优先级调度
  • D. 先来先服务

A

9. (单选题) 调度算法与作业的估计运行时间有关的是 [ ]

  • A. 先来先服务算法
  • B. 均衡算法
  • C. 短作业优先算法
  • D. 时间片轮转算法

C

10. (单选题) 关于优先权大小的论述中,正确的论述是 [ ]

  • A. 计算型作业的优先权,应高于I/O型作业的优先权
  • B. 用户进程的优先权,应高于系统进程的优先权
  • C. 长作业的优先权,应高于短作业的优先权
  • D. 资源要求多的作业,其优先权应高于资源要求少的作业
  • E. 在动态优先权中,随着作业等待时间的增加,其优先权将随之下降
  • F. 在动态优先权中,随着进程执行时间的增加,其优先权降低

F

11. (单选题) 采用SPOOLing 技术后,使得系统资源利用率[ ]

  • A. 提高了
  • B. 有时提高有时降低了
  • C. 降低了
  • D. 提高了,但出错的机会增加了

A

12. (单选题) 虚拟设备是靠 [ ] 技术来实现的。

  • A. 通道
  • B. 缓冲
  • C. SPOOLing
  • D. 控制器

C

13. (单选题) 磁盘设备的I/O控制主要是采取的方式是 [ ]

  • A. 位
  • B. 字节
  • C. 帧
  • D. DMA

D

14. (单选题) 下面关于设备属性的论述中,正确的是 [ ]

  • A. 字符设备的基本特征是可寻址的,即能指定输入的源地址和输出的目标地址
  • B. 共享设备必须是可寻址的和可随机访问的设备
  • C. 共享设备是指同一时间内允许多个进程同时访问的设备
  • D. 在分配共享设备和独占设备时都可能引起进程死锁

B

15. (单选题) 下列算法中用于磁盘移臂调度的是 [ ]

  • A. 时间片轮转法
  • B. LRU算法
  • C. 最短寻找时间优先算法
  • D. 优先级高者优先算法

C

16. (单选题) 在I/O设备控制方式的发展过程中, 最主要的推动力是 [ ]

  • A. 提高资源利用率
  • B. 提高系统吞吐量
  • C. 减少CPU对I/O控制的干预
  • D. 提高CPU和I/O设备并行操作的程

C

17. (单选题) CPU输出数据的速度远远高于打印机的打印速度,为解决这一矛盾可采用 [ ]

  • A. 并行技术
  • B. 通道技术
  • C. 缓冲技术
  • D. 虚拟技术

C

C11

List and briefly define three techniques for performing I/O.

列出并简单定义执行 I/O 的三种技术。

  • 可编程 I/O:处理器代表进程给 I/O 模块发送给一个 I/O 命令,该进程进入忙等待,等待操作的完成,然后才可以继续执行。
  • 中断驱动 I/O:处理器代表进程向 I/O 模块发送一个 I/O 命令,然后继续执行后续指令,当 I/O 模块完成工作后,处理器被该模块中断。如果该进程不需要等待 I/O 完成,则后续指令可以仍是该进程中的指令,否则,该进程在这个中断上被挂起,处理器执行其他工作。
  • 直接存储器访问(DMA):一个 DMA 模块控制主存和 I/O 模块之间的数据交换。为传送一块数据,处理器给 DMA 模块发送请求,只有当整个数据块传送完成后,处理器才被中断。

What is the difference between logical I/O and device I/O?

逻辑 I/O 和设备 I/O 有什么区别?

  • 逻辑 I/O:逻辑 I/O 模块把设备当作一个逻辑资源来处理,它并不关心实际控制设备的细节。逻辑 I/O 模块代表用户进程管理的一般 I/O 功能,允许它们根据设备标识符以及诸如打开、关闭、读、写之类的简单命令与设备打交道。

  • 设备 I/O:请求的操作和数据(缓冲的数据、记录等)被转换成适当的 I/O 指令序列、通道命令和控制器命令。可以使用缓冲技术,以提高使用率。

What is the difference between block-oriented devices and stream-oriented devices?

面向块的设备和面向流的设备有什么区别?请举例说明。

  • 面向块的设备将信息保存在块中,块的大小通常是固定的,传送过程中一次传送一块。通常可以通过块号访问数据。磁盘和USB智能卡都是面向块的设备。(大多是辅存设备)
  • 面向流的设备以字节流的方式输入/输出数据,它没有块结构。终端、打印机、通信端口、鼠标和其他指示设备以及其他大多数非辅存设备,都是属于面向流设备。

Why would you expect improved performance using a double buffer rather than a single buffer for I/O?

为什么希望用双缓冲区而不是单缓冲区来提高 I/O 的性能?

对于面向块的传送,我们可以粗略地估计执行时间为max[C,T]。因此,若C<= T,则有可能使面向块的设备全速运行;另一方面,若C>T,则双缓冲能确保该进程不需要等待I/O。

What delay elements are involved in a disk read or write?

在磁盘读或写时有哪些延迟因素?

  • 寻道时间
  • 旋转延迟
  • 存取时间
  • 传输时间

Briefly define the disk scheduling policies illustrated in Figure 11.7.

简单定义图 11.7 中描述的磁盘调度策略。

  • FIFO(先进先出):按顺序处理队列中的项目。
  • SSTF(最短服务时间优先):选择使磁头臂从当前位置开始移动最少的磁盘I/O请求。
  • SCAN(电梯算法):要求磁头臂仅沿一个方向移动,并在途中满足所有未完成的请求,直到它到达这个方向上的最后一个磁道。
  • C-SCAN(循环扫描):把扫描限定在一个方向上。因此,当访问到沿某个方向的最后一个磁道时,磁头臂返回到磁盘相反方向末端的磁道。

Briefly define the seven RAID levels.

简单定义图 7 层 RAID。

  • RAID 0:条带化、非冗余
  • RAID 1:镜像、被镜像
  • RAID 2:并行访问、通过汉明码实现冗余
  • RAID 3:并行访问、交错位奇偶校验
  • RAID 4:独立访问、交错块奇偶校验
  • RAID 5:独立访问、交错块分布奇偶校验
  • RAID 6:独立访问、交错块双重分布奇偶校验

What is the typical disk sector size?

典型的磁盘扇区大小是多少?

512 Byte

  • 2
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1.操作系统概述 操作系统的形成,操作系统的定义与功能,操作系统的分类 2.处理机管理 多道程序设计技术,用户与操作系统的两种接口,进程的定义、特征和基本状态,进程控制块(PCB)和控制块队列(运行、就绪、阻塞),进程的各种调度算法(先来先服务、时间片轮转、优先数、多级队列),进程管理的基本原语(创建、撤消、阻塞、唤醒),作业作业调度算法(先来先服务、短作业优先、响应比高者优先)。 3.存储管理 地址的静态重定位和动态重定位,一连续区存储管理,固定分区存储管理,可变分区存储管理,空闲区的合并,分区的管理与组织方式(表格法、链表法、双链表法),分页式存储管理,页表、快表及地址转换过程,内存块的分配与回收(存储分块表、位示图、链表),虚拟存储器的概念,请求分页式存储管理,缺页与缺页断位,缺页断与页面淘汰,页面淘汰算法(先进先出、最近最久未用、最近最少用、最优),页面走向,缺页断率,抖动,异常现象。 4.设备管理 计算机设备的分类(基于从属关系、基于分配特性、基于工作特性),记录间隙,设备管理的目标与功能,输入/输出的处理步骤,设备管理的数据结构(SDT、DCB、IVT),独享设备的分配,共享磁盘的调度算法(先来先服务、最短查找时间优先、电梯、向扫描),设备控制器,数据传输的方式(循环测试、断、直接存储器存取、通道),I/O的缓冲技术(缓冲、双缓冲、多缓冲、缓冲池),虚拟设备,SPOOLing技术。 5.文件管理 文件,文件系统,文件的逻辑结构(流式文件、记录式文件),文件的物理结构(连续文件、串联文件、索引文件),文件的存取(顺序、随机),磁盘存储空间的管理(位示图、空闲区表、空闲块链),文件控制块(FCB),目录的层次结构(一级目录,二级目录、树型),主目录,根目录,绝对路径,相对路径,按名存取的实现,文件共享,文件保护,文件上的基本操作。 6.进程间的制约关系 与时间有关的错误,资源竞争——互斥,协同工作——同步,信号量,信号量上的P、V操作,用P、V操作实现互斥,用P、V操作实现同步,用P、V操作实现资源分配,死锁,死锁产生的必要条件,死锁的预防,死锁的避免,死锁的检测与恢复,银行家算法,进程间的高级通信。 7.操作系统实例分析 Windows操作系统,Linux操作系统,MS-DOS操作系统
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值