操作系统概念课后答案

操作系统概念课后答案

【篇一:操作系统概念第七版答案(含编程代码)】

> chapter 1

1.1 in a multiprogramming and time-sharing environment, several users share the system simultaneously. this situation can result in various security problems. a. what are two such problems?

b. can we ensure the same degree of security in a time-shared machine as in a dedicated machine? explain your answer.

answer:

a. stealing or copying one’s programs or data; using system resources (cpu, memory, disk space, peripherals) without proper accounting.

b. probably not, since any protection scheme devised by humans can inevitably be broken by a human, and the more complex the scheme, the more difficult it is to feel confident of its correct implementation.

1.2 the issue of resource utilization shows up in different forms in different types of operating systems. list what resources must be managed

carefully in the following settings: a. mainframe or minicomputer systems b. workstations connected to serversc. handheld computers

answer:

a. mainframes:memory and cpu resources, storage, network bandwidth.

b. workstations: memory and cpu resouces

c. handheld computers: power consumption, memory resources.

1.3 under what circumstances would a user be better off using a timesharing system rather than a pc or single-user workstation?

answer: when there are few other users, the task is large, and the hardware is fast, time-sharingmakes sense. the full power of the system can be brought to bear on the user’s problem. the problemcan be solved faster than on a personal computer. another case occurs when lots of other users need resources at the same time.

a personal computer is best when the jo

b is small enough to be executed reasonably on it and when performance is sufficient to execute the prog ram to the user’s satisfaction.

1.4 which of the functionalities listed below need to be supported by the operating system for the following two settings: (a) handheld devices and (b) real-time systems. a. batch programmingb. virtual memoryc. time sharing

answer: for real-time systems, the operating system needs to support virtual memory

and time sharing in a fair manner. for handheld systems,the operating system needs to provide virtual memory, but does not need to provide time-sharing. batch programming is not necessary in both settings.

1.5 describe the differences between symmetric and asymmetric multiprocessing.what are three advantages and one disadvantage of multiprocessor systems?

answer: symmetric multiprocessing treats all processors as equals, and i/o can be processed on any cpu. asymmetric multiprocessing has one master cpu and the remainder cpus are slaves. the master distributes tasks among the slaves, and i/o is usually done by the master only.

multiprocessors can save money by not duplicating power supplies,housings, and peripherals. they can execute programs more quickly and can have increased reliability. they are also more complex in both hardware and software than uniprocessor systems.

1.6 how do clustered systems differ from multiprocessor systems? what is required for two machines belonging to a cluster to cooperate to provide a highly available service?

answer: clustered systems are typically constructed by combining multiple computers into a single system to perform a computational task distributed across the cluster. multiprocessor systems on the other hand could be a single physical entity comprising of multiple cpus. a clustered system is less tightly coupled than a multiprocessor

system.clustered systems communicate using messages, while processors in a multiprocessor system could communicate using shared memory.

in order for twomachines to provide a highly available service, the state on the two machines should be replicated and should

be consistently updated. when one of the machines fail, the other could then take-over the functionality of the failed machine.

1.7 distinguish between the client-server and peer-to-peer models of distributed systems.

answer: the client-server model firmly distinguishes the roles of the client and server. under this model, the client requests services that are provided by the server. the peer-to-peer model doesn’t have such strict roles. in fact, all nodes in the system are considered peers and thus may act as either clients or servers - or both. a node may request a service from another peer, or the node may in fact provide such a service to other peers in the system.

for example, let’s consider a system of nodes tha t share cooking recipes.under the client-server model, all recipes are stored with the server. if a client wishes to access a recipe, it must request the recipe from the specified server. using the peer-to-peer model, a peer node could ask other peer nodes

for the specified recipe.

the node (or perhaps nodes) with the requested recipe could provide it to the requesting node. notice how each peer may act as both a client (i.e. it may request recipes) and as a server (it may provide recipes.)

1.8 consider a computing cluster consisting of twonodes running adatabase.describe two ways in which the cluster software can manage access to the data on the disk. discuss the benefits and disadvantages of each.

answer: consider the following two alternatives: asymmetric clustering and parallel clustering. with asymmetric clustering, one host runs the database application with the other host simply monitoring it. if the server fails, the monitoring host becomes the active server. this is appropriate for providing redundancy. however, it does not utilize the potential processing power of both hosts. with parallel clustering, the database application can run in parallel on both hosts. the difficulty implementing parallel clusters is providing some form of distributed locking mechanism for files on the shared disk.

1.9 how are network computers different from traditional personal computers? describe some usage scenarios in which it is advantageous to use network computers.

answer: a network computer relies on a centralized computer for most of its services. it can therefore have a minimal operating system to manage its resources. a personal computer on the other hand has to be capable of providing all of the required functionality in a standalonemanner without relying on a centralized manner. scenarios where administrative costs are high and where sharing leads to more efficient use of resources are precisely those settings where network computers are preferred.

1.10 what is the purpose of interrupts? what are the differences between a trap and an interrupt? can traps be generated intentionally by a user program? if so, for what purpose?

answer: an interrupt is a hardware-generated change-of-flow within the system. an interrupt handler is summoned to deal with the cause of the interrupt; control is then returned to the interrupted context and instruction. a trap is a software-generated interrupt. an interrupt can be used to signal the completion of an i/o to obviate the need for device polling. a trap can be used to call operating system routines or to catch arithmetic errors.

1.11 direct memory access is used for high-speed i/o devices in order to avoid increasing the cpu′s execution load.

a. how does the cpu interface with the device to coordinate the transfer?

b. how does the cpu know when the memory operations are complete?

c. the cpu is allowed to execute other programs while the dma controller is

transferring data. does this process interfere with the execution of the user programs? if so, describe what forms of interference are caused.

answer: the cpu can initiate a dma operation by writing values into special registers that can be independently accessed by the device.the device initiates the corresponding operation once it receives a command from the cpu. when the device is finished with its operation, it interrupts the cpu to indicate the completion of the operation.

both the device and the cpu can be accessing memory simultaneously.the memory controller provides access to the memory bus in a fair manner to these two entities.

a cpu might therefore be unable to issue memory operations

at peak speeds since it has to compete with the device in order to obtain access to the memory bus.

1.12 some computer systems do not provide a privileged

mode of operation in hardware. is it possible to construct a secure operating system for these computer systems? give arguments both that it is and that it is not possible.

answer: an operating system for a machine of this type would need to remain in control (or monitor mode) at all times. this could be accomplished by two methods:

a. software interpretation of all user programs (like some basic,java, and lisp systems, for example). the software interpreter would provide, in software, what the hardware does not provide.

b. require meant that all programs be written in high-level languages so that all object code is compiler-produced. the compiler would generate (either in-line or by function calls) the protection checks that the hardware is missing.

1.13 give two reasons why caches are useful.what problems do they solve? what problems do they cause? if a cache can

be made as large as the device for which it is caching (for instance, a cache as large as a disk), why not make it that large and eliminate the device?

answer: caches are useful when two or more components need to exchange data, and the components perform transfers at differing speeds.caches solve the transfer problem by providing a buffer of intermediate speed between the components. if the fast device finds the data it needs in the cache, it need not wait for the slower device. the data in the cache must be kept consistent with the data in the components. if a omponent has a data value change, and the datum is also in the cache, the cache must also be updated. this is especially a problem on multiprocessor systemswhere more than one process may be accessing a

datum.acomponent may be eliminated by an equal-sized cache, but only if: (a) the cache and the component have equivalent state-saving capacity (that is,if the component retains its data

when electricity is removed, the cache must retain data as well), and (b) the cache is affordable, because faster storage tends to be more expensive.

1.14 discuss, with examples, how the problem of maintaining coherence of cached data manifests itself in the following processing environments:

a. single-processor systems

b. multiprocessor systems

c. distributed systems

answer: in single-processor systems, the memory needs to

be updated when a processor issues updates to cached values. these updates can be performed immediately or in a lazy manner. in amultiprocessor system,different processors might be caching the same memory location in its local caches. when updates are made, the other cached locations need to be invalidated or updated. in distributed systems, consistency of cached memory values is not an issue. however, consistency problems might arise when a client caches file data.

1.15 describe a mechanism for enforcing memory protection

in order to prevent a program from modifying the memory associated with other programs.

answer: the processor could keep track of what locations are associated with each process and limit access to locations

that are outside of a program’s extent. information regarding the exten t of a program’s memory could be maintained by using base and limits registers and by performing a check for every memory access.

1.16 what network configuration would best suit the following environments? a. a dormitory floor

b. a university campus

c. a state

d. a nation

answer:

a. a dormitory floor - a lan.

b. a university campus - a lan, possible a wan for very large campuses.

c. a state - awan.

d. a nation - a wan.

1.17 define the essential properties of the following types of operating systems: a. batch

b. interactive

c. time sharing

d. real time

e. network

f. parallel

g. distributed

h. clustered

i. handheld

【篇二:操作系统概念_第六版_重点部分_中文答案 -】urposes of an operating system?

1 to provide an environment for a computer user to execute programs on computer hardware in a convenient and ef?cient manner.

2 to allocate the separate resources of the computer as needed to solve the problem given. the allocation process should be as fair and ef?cient as possible.

3 as a control program it serves two major functions: (1) supervision of the execution of user programs to prevent errors and improper use of the computer, and (2) manage- ment of the operation and control of i/o devices.

? 环境提供者,为计算机用户提供一个环境,使得能够在计算机硬件上方便、高效的执行程序 ? 资源分配者,为解决问题按需分配计算机的资源,资源分配需尽可能公平、高效 ? 控制程序

监控用户程序的执行,防止出错和对计算机的不正当使用管理i/o设备的运行和控制

1.6 define the essential properties of the following types of operating systems: a. batch

b. interactive

c. time sharing

d. real time

e. network

f. distributed

a. batch. jobs with similar needs are batched together and run through the computer as a group by an operator or automatic job sequencer. performance is increased by attempting to keep cpu and i/o devices busy at all times through buffering, off-line operation, spooling, and multiprogramming. batch is good for executing large jobs that need little interaction; it can be submitted and picked up later.

b. interactive. this system is composed of many short transactions where the results of the next transactionmay be

unpredictable. response time needs to be short (seconds) since the user submits and waits for the result.

c. time sharing.thissystemsuses cpu scheduling and multiprogramming to provide economical interactive use of a system. the cpu switches rapidly from one user to

another. instead of having a job de?ned by spooled card images, each program readsits next control card from the terminal, and output is normally printed immediately to the screen.

d. real tim

e. often used in a dedicated application, this system reads information from sensors and must respond within

a ?xed amount of time to ensure correct perfor- mance.

e. network.

f. distributed.this system distributes computation among several physical processors. the processors do not share memory or a clock. instead, each processor has its own local memory. they communicate with each other through various communication lines, such as a high-speed bus or telephone line.

a. batch

相似需求的job分批、成组的在计算机上执行,job由操作员或自动job程序装置装载;

可以通过采用 buffering, off-line operation, spooling, multiprogramming 等技术使cpu 和 i/o不停忙来提高性能

批处理适合于需要极少用户交互的job。 b. interactive

由许多短交易组成,下一次交易的结果可能不可预知

需要响应时间短 c. time sharing

使用cpu调度和多道程序提供对系统的经济交互式使用,cpu快速地在用户之间切换一般从终端读取控制,输出立即打印到屏幕 d. real time

在专门系统中使用,从传感器读取信息,必须在规定时间内作出响应以确保正确的执行 e. network 在通用os上添加联网、通信功能远程过程调用文件共享

f. distributed 具有联网、通信功能提供远程过程调用

提供多处理机的统一调度调度统一的存储管理分布式文件系统

2.3 what are the differences between a trap and an interrupt? what is the use of each function?

answer: an interrupt is a hardware-generated change-of-?ow within the system. an

interrupt handler is summoned to deal with the cause of the interrupt; control is then re-turned to the interrupted context and instruction. a trap is a software-generated interrupt

an interrupt can be used to signal the completion of an i/o to obviate the need for device polling. a trap can be used to call operating system routines or to catch arithmetic errors.

an interrupt是硬件产生的系统内的流的改变 a trap是软件产生的“中断”。

interrupt可以被i/o用来产生完成的信号,从而避免cpu对设备的轮询 a trap可以用来调用os的例程或者捕获算术错误

2.5 which of the following instructions should be privileged? a. set value of timer. b. read the clock. c. clear memory.

d. turn off interrupts.

e. switch from user to monitor mode.

answer: the following instructions should be privileged: a. set value of timer. b. clear memory.

c. turn off interrupts.

d. switch from user to monitor mod

e.

3.7 what is the purpose of system calls?

answer: system calls allow user-level processes to request services of the operating sys- tem.

让用户级进程可以请求操作系统所提供的服务

6.3 consider the following set of processes, with the length of the cpu-burst time given in

milliseconds: processbursttime priority

p110 3 p21 1 p323 p41 4 p55 2

the processes are assumed to have arrived in the order p1, p2, p3, p4, p5, all at time 0. a. draw four gantt charts illustrating the execution of these processes using fcfs, sjf, a nonpreemptive priority (a smaller priority number implies a higher priority), and rr (quantum = 1) scheduling.

b. what is the turnaround time of each process for each of the scheduling algorithms in part a?

c. what is the waiting time of each process for each of the scheduling algorithms in part a?

d. which of the schedules in part a results in the minimal average waiting time (over all

processes)?

6.4 suppose that the following processes arrive for execution at the times indicated. each process will run the listed amount of time. in answering the questions, use nonpreemptive scheduling and base all decisions on the information you have at the time the decision must be made.

a. what is the average turnaround time for these processes with the fcfs scheduling algorithm?

b. what is the average turnaround time for these processes with the sjf scheduling algorithm?

c. the sjf algorithm is supposed to improve performance, but notice that we chose to run process p1 at time 0 because we did not know that two shorter processes would arrive soon. compute what the average turnaround time will be if the cpu is left

idle for the first 1 unit and then sjf scheduling is used. remember that processes p1 and p2 are waiting during this idle time, so their waiting time may increase. this algorithm could be known as future-knowledge scheduling.

a. 10.53 ((8-0)+(12-0.4)+(13-1.0))/3 = 10.53

b. 9.53 ((8-0)+(13-

0.4)+(9-1.0))/3 = 9.53

c. 6.86 ((14-0)+(6-0.4)+(2-1.0))/3 = 6.87

7.8 the sleeping-barber problem. a barbershop consists of a waiting room with n chairs

and the barber room containing the barber chair. if there are no customers to be served,the barber goes to sleep. if a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop.if the barber is busy but chairs are available, then the customer sits in one of the free chairs. if the barber is asleep, the customer wakes up the barber. write a program to coordinate the barber and the customers.

理发师和顾客同步,理发师必须由顾客唤醒,理发师给一个顾客理发完,要让理发完的顾客退出,让等待顾客进入,顾客互斥的占用n 个位置

//共享变量

semaphore scuthair, snumchair;// scuthair制约理发师, snumchair制约顾客 scuthair=0; snumchair=0;

barber: do {

wait(scuthair);//检查是否有顾客,无就睡眠给某个顾客理发

signal(snumchair);//让理发完的顾客退出,让等待的一个顾客进入} while (1);

customer i:

wait(snumchair);//申请占用椅子

signal(scuthair);//给理发师发一个信号坐在椅子上等着理发//共享变量

semaphore scuthair, mutexchair;// scuthair给理发师, mutexchair制约顾客对椅子的互斥占领

int number = 0;//顾客的共享变量,记录已经有的顾客数

scuthair=0; mutexchair =1;

customer i:

wait(mutexchair);//申请对共享变量number的操作(申请占用椅子) if(number = = n-1){signal(mutexchair); exit;} number = number +1;

signal(scuthair);//给理发师发一个信号 signal(mutexchair); 等待理发? 理发完毕?

wait(mutexchair);//申请对共享变量number的操作 number = number -1; signal(mutexchair); 离开理发店

barber: do {

wait(scuthair);//检查是否有顾客,无,就睡眠给某个顾客理发 } while (1);

8.13

consider the following snapshot of a system:

p0 p1 p2 p3 p4

allocation a b c d 0 0 1 2 1 0 0 0 1 3 5 4 0 6 3 2 0 0 1 4

max a b c d 0 0 1 2 1 7 5 0 2 3 5 6 0 6 5 2 0 6 5 6

available a b c d 1 5 2 0

answer the following questions using the banker’s algorithm: a. what is the content of the matrix need? b. is the system in a safe state?

【篇三:操作系统概念第七版4-6章课后题答案(中文

版)】

举两个多线程程序设计的例子来说明多线程不比单线程方案提高性能

答:1)任何形式的顺序程序对线程来说都不是一个好的形式。例如一个计算个人报酬

的程序。

2)另外一个例子是一个“空壳”程序,如c-shell和korn shell。这

种程序

必须密切检测其本身的工作空间。如打开的文件、环境变量和当前

工作目录。

4.2描述一下线程库采取行动进行用户级线程上下文切换的过程

答:用户线程之间的上下文切换和内核线程之间的相互转换是非常

相似的。但它依赖于

线程库和怎样把用户线程指给内核程序。一般来说,用户线程之间

的上下文切换涉

及到用一个用户程序的轻量级进程(lwp)和用另外一个线程来代替。这种行为通

常涉及到寄存器的节约和释放。

4.3在哪些情况下使用多内核线程的多线程方案比单处理器系统的单个线程方案提供更好

的性能。答:当一个内核线程的页面发生错误时,另外的内核线程

会用一种有效的方法被转换成

使用交错时间。另一方面,当页面发生错误时,一个单一线程进程

将不能够发挥有

效性能。因此,在一个程序可能有频繁的页面错误或不得不等待其

他系统的事件的

情况下,多线程方案会有比单处理器系统更好的性能。

4.4以下程序中的哪些组成部分在多线程程序中是被线程共享的?a.寄存值 b.堆内存 c.全局变量

d.栈内存答:一个线程程序的线程共享堆内存和全局变量,但每个

线程都有属于自己的一组寄存值和栈内存。

4.5一个采用多用户线程的多线程方案在多进程系统中能够取得比

在单处理器系统中更好

的性能吗?

答:一个包括多用户线程的多线程系统无法在多处理系统上同时使

用不同的处理器。

操作系统只能看到一个单一的进程且不会调度在不同处理器上的不

同进程的线程。因此,多处理器系统执行多个用户线程是没有性能

优势的。

4.6就如4.

5.2章节描述的那样,linux没有区分进程和线程的能力。且linux线程都

是用相同的方法:允许一个任务与一组传递给clone()系统调用的标

志的进程或线程。但许多操作系统,例如windows xp和solaris,

对进程和线程都是一视同仁。基本上,这种使用notation的系统,

一个进程的数据结构包括一个指向属于进程的不同线程的指针。区

别建模过程和在内核中线程的两种方法。

答:一方面,进程和线程被视为相似实体的系统中,有些系统代码

可以简化。例如,

一个调度器可以在平等的基础上考虑不同的进程和线程,且不需要

特殊的代码,在调度中审查有关线程的进程。另一方面,这种统一

会使进程资源限制更加困难。相反,一些额外的复杂性被需要,用

来确定哪个线程与哪个进程一致和执行重复的计数任务。

4.7由4.11给出的程序使用了pthread的应用程序编程接口(api),在程序的第c行

和第p行分别会输出什么?答:c行会输出5,p行会输出0.

4.8考虑一个多处理器系统和用多线程对多线程模式编写的多线程程序。让程序中的用户线程数量多于系统中的处理器的数量,讨论下

列情况下的性能意义: a.由程序分配的内核线程的数量比处理器少

b. 由程序分配的内核线程的数量与处理器相同

c. 由程序分配的内核线程的数量大于处理器数量但少于用户线程的

数量

答:当内核线程的数量少于处理器时,一些处理器将仍然处于空闲

状态。因为,调度图中

只有内核线程的处理器,而不是用户线程的处理器。当程序分配的

内核线程的数量

与处理器相同时,那么有可能所有处理器将同时使用。然而,当一

个内核块内的内核(因页面错误或同时援引系统调用)相应的处理

器将闲置。当由程序分配的内核线程的数量大于处理器数量时,封

锁一个内核线程并调出,换入另一个准备执行的内核线程。因此,

增加多处理器系统的利用率。

第五章 cpu调度

5.1为什么对调度来说,区分i/0限制的程序和cpu限制的程序是重

要的?

答:i/0限制的程序有在运行i/o操作前只运行很少数量的计算机操

作的性质。这种

程序一般来说不会使用很多的cpu。另一方面,cpu限制的程序利

用整个的时间片,且不做任何阻碍i/o操作的工作。因此,通过给

i/o限制的程序优先权和允许在cpu限制的程序之前运行,可以很好

的利用计算机资源。

5.2讨论以下各对调度标准在某种背景下会有的冲突 a.cpu利用率

和响应时间 b.平均周转时间和最大等待时间 c.i/o设备利用率和cpu

利用率

答:a.cpu利用率和响应时间:当经常性的上下文切换减少到最低时,cpu利用率增加。

通过减少使用上下文切换程序来降低经常性的上下文切换。但这样

可能会导致进程响应时间的增加。 b.平均周转时间和最大等待时间:通过最先执行最短任务可以使平均周转时间最短。

然而,这种调度策略可能会使长时间运行的任务永远得不到调度且

会增加他们的等待时间。

c.i/o设备利用率和cpu利用率:cpu利用率的最大化可以通过长时

间运行cpu

限制的任务和同时不实行上下文切换。i/o设备利用率的最大化可以

通过尽可能调度已经准备好的i/o限制的任务。因此,导致上下文切换。

5.3考虑指数平均公式来预测下一次cpu区间的长度,使用以下参

数值会有什么影响? a.a=0和t=100毫秒 b.a=0.99和t=10毫秒

答:当a=0和t=100毫秒时,公式总是会预测下一次的cpu区间为100毫秒。当

a=0.99和t=10毫秒时,进程最近的行为是给予更高的重量和过去

的就能成相比。因此,调度算法几乎是无记忆的,且简单预测未来

区间的长度为下一次的cpu执行的时间片。

5.4考虑下列进程集,进程占用的cpu区间长度以毫秒来计算:

进程区间时间优先级 p1 10 3 p2 1 1 p3 2 3 p4 1 4 p5 5 2

假设在时刻0以进程p1,p2,p3,p4,p5的顺序到达。

a.画出4个gantt图分别演示用fcfs、sjf、非抢占优先级(数字小

代表优先级高)和rr(时间片=1)算法调度时进程的执行过程。

b.在a里每个进程在每种调度算法下的周转时间是多少?

c.在a里每个进程在每种调度算法下的等待时间是多少?

d.在a里哪一种调度算法的平均等待时间对所有进程而言最小?答:a.甘特图略 b.周转时间

d.sjf

5.5下面哪些算法会引起饥饿

a.先来先服务

b.最短工作优先调度

c.轮换法调度

d.优先级调度

答:最短工作优先调度和优先级调度算法会引起饥饿

5.6考虑rr调度算法的一个变种,在这个算法里,就绪队列里的项

是指向pcb的指针。 a.如果把两个指针指向就绪队列中的同一个进程,会有什么效果? b.这个方案的主要优点和缺点是什么?

c.如何修改基本的rr调度算法,从而不用两个指针达到同样的效果?答.a.实际上,这个过程将会增加它的优先权,因为通过经常得到时

间它能够优先得以

运行。

b.优点是越重要的工作可以得到更多的时间。也就是说,优先级越

高越先运行。然

而,结果将由短任务来承担。

c.分配一个更长的时间给优先级越高的程序。换句话说,可能有两个

或多个时间片在

rr调度中。

5.7考虑一个运行十个i/o限制任务和一个cpu限制任务的系统。

假设,i/o限制任务一次分配给一个i/o操作1毫秒的cpu计算,但

每个i/o操作的完成需要 10毫秒。同时,假设间接的上下文切换要0.1毫秒,所有的进程都是长进程。对一个rr调度来说,以下情况时cpu的利用率是多少:a.时间片是1毫秒b.时间片是10毫秒

答:a.时间片是1毫秒:不论是哪个进程被调度,这个

调度都会为每一次的上下文切换花费一个0.1毫秒的上下文切换。

cpu的利用率是1/1.1*100=92%。

b.时间片是10毫秒:这i/o限制任务会在使用完1毫秒时间片后进

行一次上下文切换。这个时间片要求在所有的进程间都走一遍,因此,10*1.1+10.1(因为每个i / o限定任务执行为1毫秒,然后承担

上下文切换的任务,而cpu限制任务的执行10毫秒在承担一个上下

文切换之前) 。因此,cpu的利用率是20、21.1*100=94%。

5.8考虑一个实施多层次的队列调度系统。什么策略能够使一个计算机用户使用由用户进程分配的最大的cpu时间片。答:这个程序可以使分配给它的没有被完全利用的cpu时间最大化。它可以使用分配给它的时间片中的绝大部分,但在时间片结束前放弃cpu,因此提高了与进程有关的优先级。

5.10解释下面调度算法对短进程编程度上的区别: a.fcfs b.rr

c.多级反馈队列

答:a.fcfs----区别短任务是因为任何在长任务后到达的短任务都将会有很长的等待时间。 b.rr-----对所有的任务都是能够相同的(给它们相同的cpu时间区间),所以,短任务

可以很快的离开系统,只要它们可以先完成。 c. 多级反馈队列和rr 调度算法相似——它们不会先选择短任务。

5.11用window xp的调度算法,下列什么是数字优先的线程。

a.相对优先级的值为realtime_priority_class的属于实体优先类型的线程

b.相对优先级的值为normal_priority_class的属于normal 类型的线程

c.相对优先级的值为high_priority_class的属于above_normal类型的线程答:a.26 b.8 c.14

5.12考虑在solaris操作系统中的为分时线程的调度算法:

a:一个优先权是10的线程的时间片是多少?优先权是55的呢?

b:假设优先权是35的一个线程用它所有的时间片在没有任何阻止的情况下,这调度算法将会分配给这个线程什么样新的优先权?

c:假设一个优先权是35的线程在时间片结束前阻止i/o操作。这调度算法将会分配给这个线程什么样新的优先权?

答:a:160和40 b:35 c:54

5.13传统unix调度在优先数和优先级间成反比关系:数字越高,优先权越低。该调度进程利用下面的方程重新计算进程的优先权一次一秒: 优先权= (最近cpu使用率/ 2 ) +基本数

这里的基本数= 60,最近的 cpu使用率是指一个表明优先权从上一次重新计算后开始进程被cpu使用的情况。

假设最近进程p1的cpu使用率是40个,p2是18 ,p3是10。当优先权重新计算后这三个进程的新的优先权是什么?在此信息的基础上,传统unix的调度会不会提高或降低cpu限制的进程的相对优先权?

答:分配给这些进程的优先权分别是80,69和65.这调度降低了cpu限制的进程的相对优先权。

相关文档
最新文档