您的当前位置:首页正文

操作系统复习题

2022-07-10 来源:意榕旅游网


操作系统复习题1-Eli(总9页)

-本页仅作为预览文档封面,使用时请删除本页-

Multiple Choice

1.What are the major activities of an operating system A:User management 理)

C:I/O system management设备管理 D:File management文件管理 Answer:BCD

B:Main Memory management(存储管

2.The way that operating system components are interconnected and modeled into a kernel can be A:Simple structure C:Layered approach Answer:ABC

3.What state is a process in when it can not run because it needs a resource to become available A:Ready C:Blocked Answer:C

4.Which are the major differences between user-level threads and kernel-level threads

A:User-level threads are unknown by the kernel, whereas the kernel is aware of kernel threads.

B:User threads are scheduled by the thread library and the kernel schedules kernel threads.

2

B:Micro kernels D:Prototype approach

B:Interrupt

D:Running

C:Kernel threads need not be associated with a process whereas every user thread belongs to a process.

D:One user-level thread can be only mapped by one kernel thread. Answer:ABC

5.Which of the following free-space management strategies are supported by an operating system A:Bit Vector C:Grouping Answer:ABCD

6.What refers to the page replacement algorithm which replaces the page that has not been used for the longest period of time A:FIFO C:OPT Answer:B

7.Which of the followings is a condition for deadlock A:Starvation

B:Circular Wait D:Mutual Exclusion

B:LRU D:LFU

B:Linked list D:Counting

C:No Preemption Answer:BCD

3

8. The basic function of the file system is accessing files by names. The function can be realized by A directory-management

B boosting the speed of the file-accessing C file-protecting

D improving the utilization of storage 9.

A main memory space B cpu management C I/O system management D Tape management

of the following strategies need base register and length register A:paging

B:segmentation

C:segmentation with paging

D:fixed sized partitions memory management Answer:ABC Concept Explanations call

系统调用。获取操作系统所提供的服务的接口。

系统调用的类型:①进程控制②文件管理③设备管理④信息维护⑤通信。 2.Critical section

4

临界区。假如某个系统有n个进程{P0,P1,…,Pn}。每个进程有一个代码段称为临界区,在该区中进程可能改变共同变量、更新一个表、写一个文件等。没有两个进程可同时在临界区内执行。

计算机的文件系统可以非常大。为了管理这些数据,需要组织它们。这种管理涉及使用目录。目录记录一个分区中所有文件的的信息,如名称、位置、大小和类型等。目录可看做符号表。它将文件名称转换成目录条目。

覆盖:一个作业的若干程序段,或几个作业的某些部分共享某一个存储空间。 引入:在多道程序环境下扩充内存的方法,用以解决在较小的存储空间中运行较大程序时遇到的问题。

原理:一个程序的几个代码段和数据段,按照时间先后来占用公共的内存空间。(并不是作业的每一部分都是时时要用的)。

把程序划分为若干个功能上相互独立的程序段,按照其自身的逻辑结构将那些不会同时执行的程序段共享同一块内存区域。

程序段先保存在磁盘上,当有关程序段的前一部分执行结束后,把后续程序段调入内存,覆盖前面的程序段。

Brief Answers

1.What is the difference between process and program What is the difference between process and thread

程序和进程的区别:

程序是完成所需求的功能时,所应采取的顺序步骤,是执行指令的有序集合。

进程是执行中的程序,包括程序计数器,进程栈和数据段,还可能包括堆。

程序和进程的区别:

①程序本身不是进程。程序只是被动实体,如存储在磁盘上的可执行文件。

进程是活动实体,不只是程序代码,还包括当前活动。随程序的执行而发生,随程序的结束而消亡。

②.多个进程可与同一程序相关。并且这些进程被当做独立的执行序列。 ③静止状态的程序和数据是相互独立的信息集合,进程中的程序和数据是一个不可分割的实体。

线程与进程的区别

①线程是CPU使用的基本单元,进程是系统工作的基本单元,资源分配的最小单位。

②线程划分的尺度小,所以并发性高,而进程划分的尺度相对较大。线程是CPU执行的基本单元,而进程是内存分配的基本单元。

5

③进程是运行中的程序,是一个动态的概念,获得了计算机资源,执行了任务。而线程是进程中的一个单一的组成部分,一叫做轻量级进程,是程序执行的最小单位。

2.What is the cause of trashing How does the system detect thrashing Once it detects thrashing, what can the system do to eliminate this problem

颠簸,频繁的页调度行为。一个进程在换页上用的时间要多于执行的时间,那么这个进程就在颠簸。 颠簸的原因:

进程总的需求大于可用帧的数量。那么有的进程就会得不到足够的帧,从而出现颠簸。

系统怎么探测颠簸

系统可通过对比多道程序的程度来估计CPU利用率的程度,以此来检测颠簸。

怎么消除

降低多道程序的程度可以消除颠簸。

3.What is spooling Describe how spooling works using printer as an example

假脱机是用来保存设备输出的缓冲区。这些设备不能接受交叉的数据流。它是OS用来协调并发输出的一种方法。

从一个应用软件打印文稿时,应用程序的输出先是假脱机到一个独立的磁盘文件上,当这个假脱机文件创建完毕,OS就将控制权交给应用程序,然后,这个假脱机文件将在后台被送往打印机打印出来。

Consider a system consisting of 4 resources of the same type that are shared by three processes,each of which needs at most 2 resources. Show that the system is deadlock free. 发生死锁的条件

假设该系统陷入死锁。这意味着,每一个进程只持有一个资源,并且正等待另一个资源。因为有3个进程和4个资源,有一个进程必须获取2个资源,该进程并不需要更多的资源。不满足死锁产生的占有并等待条件。

Comprehensive

1. Consider a memory management system with are three jobs, J1, J2, J3 , are in the memory now. J2 has 4 pages,which are stored in the 3rd ,4rh ,6rh and 8 rh block of the main memory the page size is 1024 bytes, and the main is 10K bytes, please answer the following two questions:

6

(1)Draw the page table of J2; 2100/1024=2, 2对应的帧号为6, 2100%1024=52,页偏移为52 物理地址为:6*1024+52=6196 J2的页表: 0 1 2 3

(2)If J2 meets the instruction “MOV[2100],[3100]” at its logical address 500(decimal),give the physical addresses of the two operands above.

the following snapshot of a system:

7

3 4 6 8 Allocation Available

Max

R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P0 0 0 1 2 0 0 1 2 2 1 0 0 P1 2 0 0 0 2 7 5 0 P2 0 0 3 4 6 6 5 6 P3 2 3 5 4 4 3 5 6 P4 0 3 3 2 0 6 5 2

1.How many instances of each resource type in the system 2.What is the content of the matrix need 3.Is the system in a safe state Why

4.If a request from process P2 arrives for (0,1,0,0), can the request be granted immediately

Answer:

1.各种资源的实例数量总数等于各个进程所分配的各种资源的实例数量与各种资源现有的实例数量之和。即(R1,R2,R3,R4)=(6,7,12,12)

2.Need矩阵中的各个资源的数值等于每个进程的最大需求Max矩阵-每个进程现在所分配的各个资源实例数量Allocation矩阵,即

Need R1 R2 R3 R4 P0 0 0 0 0 P1 0 7 5 0 P2 6 6 2 2 P3 2 0 0 2 P4 0 3 2 0

3.如果可以找到一个安全序列,那么该系统就处于安全状态,否则,系统就处于不安全状态。

因为找到序列满足安全要求,所以系统安全。

4.P2的Request2 =(0,1,0,0)。首先检测Request2 Allocation Need Available

R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P0 0 0 1 2 0 0 1 2 2 0 0 0 P1 2 0 0 0 2 7 5 0 P2 0 1 3 4 6 5 2 2 P3 2 3 5 4 4 3 5 6

8

P4 0 3 3 2 0 6 5 2

必须确定此状态是否安全,为此,执行安全算法。找不到一安全序列,故不能立即允许进程P2的这个请求。 3.Consider the following page reference string:

2、3、4、5、3、4、1、2、3、5、1、4、2、4、5、1、3、2、1、3. Please write processes of the following replacement algorithms and give the number of page faults, assuming 3 frames Remember all frames are initially empty, so your first unique pages will all cost one fault each.

1.FIFO replacement:先进先出页置换 置换最旧的页

2.LRU replacement:最近最少使用页置换 置换最长时间没有使用的页 3.Optimal replacement:最优页置换 置换将来最长时间不使用的页 Answer:

FIFO: 2 3 4 5 3 4 1 2 3 5 1 4 2 4 5 1 3 2 1 3

2 2 2 5 5 5 3 3 3 4 4 4 1 1 1 3 3 3 1 1 1 5 5 5 2 2 2 3 3 4 4 4 2 2 2 1 1 1 5 5 5 2 页错误次数:15

LRU: 2 3 4 5 3 4 1 2 3 5 1 4 2 4 5 1 3 2 1 3 2 2 2 5 1 1 1 5 5 5 2 2 1 1 1 3 3 3 3 2 2 2 1 1 1 5 5 5 2 4 4 4 4 3 3 3 4 4 4 4 3 3 页错误次数:15

OPT: 2 3 4 5 3 4 1 2 3 5 1 4 2 4 5 1 3 2 1 3 2 2 2 5 5 5 5 5 1 1 3 3 3 3 3 1 4 4 3 4 4 1 2 2 2 2 2

页错次数:10

运用FIFO

9

the following set of processes, with the length of the CPU burst time given in milliseconds:

Process Arrival time Burst time(ms) Priority

P1 0 3 3 P2 2 6 5 P3 4 4 1 P4 6 5 2 P5 8 2 4

Draw Gantt charts illustrating the execution of these processes of the following scheduling algorithms,and calculate the waiting time of each process as well as the average waiting time of each scheduling algorithms.

1.Preemptive and non-preemptive SJF

2.Preemptive priority(a smaller priority number implies a higher priority) 3.RR(quantum=4ms)

Preemptive SJF : P PPPPP 0 3 4 8 10 15 20

Non-preemptive SJF: PPPPP 0 3 9 11 15 20

Preemptive priority: P PPPPP 0 3 4 8 13 15 20

RR: PPPPPPP 0 3 7 11 15 17 19 20 RR: PPPPPPP 0 3 7 11 15 17 19 20 5.

10

因篇幅问题不能全部显示,请点此查看更多更全内容