操作系统考试题1

更新时间:2023-05-25 05:18:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

Multiple Choice

1.What are the major activities of an operating system?

A:User management B:Main Memory management

C:I/O system management D:File management

Answer:BCD

2.The way that operating system components are interconnected and modeled into a kernel can be?

A:Simple structure B:Micro kernels

C:Layered approach D:Prototype 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 B:Interrupt

C:Blocked D:Running

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. 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 B:Linked list

C:Grouping D:Counting

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 B:LRU

C:OPT D:LFU

Answer:B

7.Which of the followings is a condition for deadlock?

A:Starvation B:Circular Wait

C:No Preemption D:Mutual Exclusion

Answer:BCD

8.Which 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

2.Critical section

临界区就是进程中关于临界资源的代码段。

无论是硬件还是软件都用临界资源,对临界资源的访问要互斥的进行,以防止访问冲突。程序中调用临界资源的代码段就叫做临界区。

3.Directory

目录为了对文件实施有效的管理,将他们妥善的管理起来。

目录用来记录磁盘上某一个分区中所有文件的信息,可以看成是一个标志的表,用来将文件的名字翻译成一个记录的实体,该实体包括文件的名字、类型、地址、文件长度,所有者等信息。

4.Overlay

覆盖为了能让进程比他们分配到的内存空间大,基本思想是任何时候在内存中只保存所需指令和数据,当需其他指令时,他们会装入到刚刚不再需要的指令的内存空间内。从而进程可以得到比自己已被分配的资源更大的资源。

Brief Answers

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

程序是完成所需求的功能时,所应采取的顺序步骤,是执行指令的有续集和,进程是执行中的程序,包括程序计数器,进程堆栈段,数据段。

程序和进程的区别:

1.程序是一个静态的概念,作为一种资源可以永久的存放在磁盘中,进程是程序执行的动态活动过程,随程序的执行而发生,随程序的结束而消亡。

2.静止状态的程序和数据是相互独立的信息集合,进程中的程序和数据是一个不可分割的实体。

3.一个程序可以对应多个进程

程序是静态的,是永久存在的,而进程是动态的,且存在生命周期。程序是一组有序的指令集合,进程是程序及数据在计算机上的一次执行。

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

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

父进程和子进程有自身的数据和代码空间,而同一个进程的各个线程是共享进程的代码和数据,文件等,自己保存寄存器的值。

进程是资源分配的最小单位,线程是程序执行的最小单位。

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不断地处理请求,却没有足够的时间执行请求,导致进程以为CPU在空闲没有请求可以处理,从而不断发送请求,最终是CPU无法执行请求。

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

假脱机是利用高速的共享设备,将独享设备变成逻辑上客共享的虚拟设备的技术,以提高设备的利用率。

假脱机技术使打印机在任意时刻只有一个用户的后台程序在使用它,其他用户的请求被放在一个等待序列中,所以就不存在资源冲突的现象,即没有死锁出现。

4.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.

因为一共有4个资源,所以3个人无论怎么分配,都至少有一个人持有两个资源,也就是说至少有一个人可以顺利执行,其他人等他执行完便可以相继的顺利执行了,所以不存在死锁的现象。

Comprehensive

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

Draw the page table of J2;

If J2 meets the instruction "MOV [2100],[3100]"(decimal) at its logical address

2.Consider the following snapshot of a system:

Allocation Max Available

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.资源的总数等于各个进程占有的资源(Allocation)+当前可以获得的资源(Available)。即(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.判断系统是否安全,就是找到一个进程资源分配的序列,使得各个进程都可以安全的执行,且一个进程执行后,他占有的资源(Allocation)将加到可获得的资源(Available)中。因为P0,P3,P4,P1,P2是安全的,所以系统安全。

4.首先判断请求是否小于Need矩阵,否,则不可以。然后判断请求是否小于可获得的资源,否,则不可以。假装分配了资源,看看是否能找到安全的序列,否,则不可以。易知该系统不存在安全序列,所以不能立即执行。

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

4.Consider 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:

Non-preemptive SJF:

0 3 9 11 15 20

Preemptive priority: 0 3 4 8 13 15 20

RR: 5.Consider four processes A,B,C,and D,sharing a same buffer,Process A inputs one object into the buffer each time, and it will not input the next object until that all process B,C and D have accessed the object once.

1.How many semaphores will be needed for correct communication among process A,B,C,D?

本文来源:https://www.bwwdw.com/article/zmt4.html

Top