首页 > 代码库 > 《操作系统精髓与设计原理》习题第三章

《操作系统精髓与设计原理》习题第三章

第三章习题

3.10.1关键术语

阻塞态:进程在某些事件发生之前不能执行,等待这种事件发生的状态。

退出态:操作系统从可执行进程组中释放出的进程,自身停止了,或者因某种原因被取消。

内核态:某些指令只能在特权状态下执行,而这种特权状态称为内核态。

子进程:由一个进程创建的进程,该进程的终止受父进程的影响。

中断:由外部事件引发进程挂起,CPU转而去处理发起中断的事件,并处理结束后恢复进程的执行。

模式切换:CPU由用户态和核心态之间相互切换。

新建态:进程创建时仅仅创建了对应的进程控制块而没有在内存中创建相应的映像,此时进程的代码和数据在外存中

进程切换:在某一时刻,一个正在运行的进程被中断,操作系统指定另外一个进程为运行态,并把控制权交给它。包括为前一个进程保存进程控制块和上下文信息,并把它们替换成第二个进程的。

交换:内存将一个内存中一个区域的内容与辅助存贮器中一个区域的内容互相交换的过程。

程序状态字:包含状态代码、执行模式,以及其他反应进程状态的信息的单个寄存器或寄存器组。

陷阱:转向某个指定地址的非编程的条件转移,是由硬件自动激活的,跳转发生的位置会被记录下来。

进程控制块:操作系统中进程信息的描述,是一个数据结构,包含有进程标识信息、处理器状态信息、进程控制信息等。

进程映像:一个进程的所有组成部分,包括程序、数据、栈和进程控制块。

进程:进程是进程实体的运行过程,是系统资源分配和调度的基本单位。

3.10.2复习题

3.1什么是指令跟踪(轨迹)?(What is an instruction trace?)

An instruction trace for a program is the sequence of instructions that execute for that process.一个进程运行指令的序列称作指令轨迹。

3.2通常哪些事件会导致创建一个进程?(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.新的批处理作业;交互登陆(终端用户登陆到系统);操作系统因为提供一项服务而创建;由现有的进程派生。

3.3对于图3.6中模型,简单的定义每个状态。Briefly define each state.

Running:The process that is currently being executed.Ready:A process that is prepared(准备) to execute when given the opportunity.Blocked:A process that cannot execute until some event occurs(发生), such as the completion(完成) of an I/O operation.New:A process that has just been created but has not yet been admitted(承认) to the pool of executable processes by the operating system.Exit:A process that has been released from the pool of executable processes by the operating system, either because it halted(停止) or because it aborted for some reason.

3.4抢占一个进程是什么意思?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.进程抢占发生在一个正在运行的进程被处理器中断然后让另一个进程运行。

3.5什么是交换,其目的是什么?What is swapping and what is itspurpose?

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.6为什么图3.9b有两个阻塞态?Why does Figure3.9 has 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).

3.7列出挂起进程的四个特点。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(移动).1.进程不会立即执行2.进程可能等待一个事件的发生,如果在等待,阻塞条件和挂起条件是相互独立的,并且阻塞等待事件的发生不会让进程可执行。3.进程被一个代理置为挂起的状态,这个代理可以是它自己,一个父进程或者操作系统,其目的是防止其运行。4.直到这个进程在这个代理明确地命令移动状态,这个进程才会改变状态。(这个进程需要显示的去申请解除挂起状态)。

3.8对于哪类实体,操作系统为了管理它而维护其信息表?For what types of entities does the operating system maintain tables of information for management purposes?

The OS maintains tables for entities related to memory, I/O,files, and process.

3.9列出进程控制块中的三类信息。List three general(一般) categories(类别) of information in a process control block.

Process identification(标识符), processor state information, and process control informations.

3.10为什么需要两种模式(用户态和内核态)?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 this restrictions, so that it can perform(执行) its tasks.

3.11为了创建一个进程操作系统执行哪些步骤?What are the steps performed by an operating system to create a new process?

1.Assign a unique process identifier to the new process.2.Allocate space for the process.3.Initialize the process control block.4.Set the appropriate linkages.5.Create or expand other data structures. 1.给进程分配一个唯一的标识符。2.为进程分配空间。3.初始化进程控制块。4.设置正确的连接(例如操作系统把每个调度队列保存成链表,则新进程必须放置在就绪或就绪/挂起队列)。5.创建或扩充其他数据结构。

3.12中断和陷阱有什么区别?What is the difference between an interrupt and a trap?

An interrupt is due to some sort of event that is external to an independent of the currently running process, such as the completion of an I/O operation.A trap relates to an error or exception condition generated within the currently running process, such as an illegal(非法的) file access attempt(试图).

3.13举出中断的三个例子。Give three examples of an interrupt.

Clock interrupt, I/O interrupt, memory fault.

3.14模式切换和进程切换有什么区别?What is the difference between a mode switch and a process switch?

A mode switch may occur without changing the state of the process that is currently in the Running state. A process switch involves taking the currently executing process out of the Running state in favor of another process.The process switch involves saving more state information.

                                                                ——10月24日——

《操作系统精髓与设计原理》习题第三章