(完整word版)操作系统英文版课后习题答案整理(word文档良心出品)


2023年12月22日发(作者:简单的个人主页网站制作)

1.1What are the three main purposes of an operat ing system?

⑴ In terface betwee n the hardware and user;

(2) man age the resource of hardware and software;

(3) abstracti on of resource;

Answer;

• Tb provide an environment ksr a computer user to execute programs on computer h日rchvare in n convenient and efficient manner.

• Tb allocate the separate resources of the computer as needed to st)ke the problem given.

The allcxation prtxzess should b? as fair and efficient as possible.

• Asa control program it serves two major functions; (1) supervision of the execution

user programs to prevent errors and improper use of the computer, and (2) management

of the operatioji and control of I/O devices.

1.2 List the four steps that are necessary to run a program on a completely dedicated machine. Preprocess

ing > Process ing > Linking > Executi ng.

Answer:

Reserxe machine time*

b* Manually load program into memory.

u Load starting address and begin exe匚Lition.

cL Monitor and control execution of program fr(im console.

1.6 Define the essential properties of the following types of operating systems:

a. Batch

b. In teractive

c. Time shar ing

d. Real time

e. Network

f. Distributed

Answer

a” Batch, Jobs w计h similar reeds are batched together and run through the computer as a

group by ^r operator or automatic jc)b s^quenc^r. [^rformanct? i$ incr^a^ed by

atteiTipting to keep CPU 3nd I/O devices busv 311 timesi through buffering, off-line

operation^ spooling, and multiprogramming. Batch is good for executing

】arge jobs thjit

need little interacticm; it can be submitted and piuked up later.

b. Interactive. This system is cumpofied of m^nv short transactions where the results of the

next transactiiin may be unpredictablen Respond time needs tn be short (sectwids) since

the user submits and waik for the result.

u Time sharing. This systems u

船呂匚

Pl sch<*duling ^nd multi programming to pmvidu

eConoiniCcil interactive use of

system. The CPL switches rapidly iri>m one user tn

another Instead of having a job defined by spcxiled card images^ each program reads

its next control card from the terminab and output is normally printed immediately to the

screen.

(_L Real time. Often tisvci in a dedicated application, this system reads information from

sensors and must respond within a fixed amount of time to ensure correct performance.

e. Network.

f. Distributed .This system distributes computation among several physical processors” The

prtKessors do not share menion- or a clock. Instead, each pnxzessor has its own kxzal

memory. They communicate with each other through various communication linesf such as

a high-speed bus or telephone line.

1.7 Wehave stressed the need for an operating system to make efficient use of the computing

hardware. When is it appropriate for the operating system to forsake this principle and to waste ” resources?

Why is such a system not really wasteful?

Answer Single-user systems should maximize use of the system for the user A GUI

might "xvastc * GPL' cycles, but it optimizes the userTs interaction with the system.

2.2 How does the distinction between monitor mode and user mode function as a rudimentary form of protecti

on (security) system?

Answer: By establishing a set of privileged instructions that can be executed only when in tlie

m(snitnr mt)def the tiperating system is assured of controlling the entire system at all times.

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

fun cti on?

Answer An interrupt is a ha rd v a re-^en era ted change-of-flow within the system. An

interrupt handler is summoried to deal with the cause oF the interrupt; control is then re

turned to the interrupted context and instruction. A trap is a software-j;enerated interrupt. An

interrupt can be uwd to signal the compJrtion “f an I/O obviate the nevd for polling. A trap can

be used ti> call operating svstem routines or to catch arithmetic errors.

2.5 Which of the follow ing in structi ons 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.

OS Exercise Book

3

Class No. Name

Answer: The following instructions should be privileged:

Set value of timer,

b. Clear memory.

J

c. Turn off interrupts.

d. Switch from user to monitor mode*

2.8 Protecting the operating system is crucial to ensuring that the computer system operates correctly.

Provision of this protection is the reason behind dual-mode operation, memory protection, and the timer. To

allow maximum flexibility, however, we would also like to place mini mal con stra ints on the user.

The following is a list of operations that

of in structi ons that must be protected?

a. Change to user mode.

b. Change to mon itor mode.

c. Read from mon itor memory.

d. Write into mon itor memory.

e. Fetch an instruction from monitor memory.

f. Tur n on timer in terrupt.

g. Turn off timer interrupt.

are normally protected. What is the

minimal

set

Answer: The minimal 5et of instructions that must be protected are:

a. Change to monitor mtxle.

b. Read from monitor memory*

c. Write into monitor me mor v.

J

d. Turn off timer interrupt

3.6 List five services provided by an operat ing system. Explain how each provides convenience to the users.

Explain also in which cases it would be impossible for user-level programs to provide these services.

Answer;

« Program execution. The operating system loads thv contents (or sections) of a file into

menidry and begins its execution. A user-level program could not be trusted to properly

allocate CPU time.

• I/O operations. Disks, tapes, serial lines; and other devices must be communicated with at

a very low level. The user need only specify the dev ice and the operation to perform (in it,

while the system converts that request into

User-level pnjgrams cannot be trusted to only access devices they should have access to and

to only access them when they otherwise unused.

« File-system manipulation, fhere are manv details in file creation, deletion/ alkKation, and

naming that users should not have to perform. Blocks of disk space are used by files and

must be tracked, deleting a file requires remo ing the name file information and freeing the

prc^grams could neither ensure adherence to protect]on methcxis nor be trusted to allocate

only free block吕

and deallocate bkxzks on file deletion.

J

• Communications. Message passing between systems requires messages be turned into

packets of information, sent to the network controller, trannmitted across a community tk>ns

medium, and reassembled by the destination system.卩acket ordering and data correction

must take place. Again, user program吕

might not c(sordinate access to the network dev ice,

or they might receive packets destined tor other processes^

» Error detection. Error detection (occurs at both the hardware and soFtwart? levels. At tlie

hardware level, all data transfers must be inspected to ensure that data hax e not been

corrupted in transit All data on media must be checked to be sure they have not changed

since they uritten to the media. At the software level, media must be

checked for data ccnsistencj^; for instance, do the number of allocated and unallocated blocks

of storage match the total number on the device. There, errors are frequently pnxzess-independent (for instance, the

匚omiption of data on a disk)5 sc there must be a global program

(the operating system) that handles all h pes of errors. Also, by having errors pmcessed by

the operating system, processes need not contain code to catch and ccjrrect all the ernjrs

possible on a system.

3.7 What is the purpose of system calls?

Answer; Sv>ttn'. dlltnv ustr-levtl

tem.

3.10 What is the purpose of system programs?

lu request str ices nt 11 it? uperating svs-

JVUSWCE Svstcm programs can be thought of as bundle!ti of useful system oils. Thevr

provide

bcisic functidcaliU users and sci users do not need to wnte their cwn programs to s<>kre

comnicMi problems,

4.1 MS-DOS provided no means of con curre nt process ing. Discuss three major complicati ons

that con curre nt process ing adds to an operat ing system.

OS Exercise Book

Answer:

5

Class No. Name

* A method of time sharing must be implemented to allow each of several prcxzesses to have

access to the system. This method involves the preemption of processes that do not

voluntarily give up the CPU (by using a system ca1]r for instance) and the kernel being

reentrant (so more than one prtxzess may be executing kernel code concurrently).

・[Vocesses and system resources must have protections and must be protected from each

other. Any given process must be limited in the amount of memory it can use and tlie ope

Mt ions

can perform on devices like di^ks.

• Care must be taken in the kernel to prevent deadkxzks between prucesses, so processes

aren*t waiting for each other's allocated rest>urces,

4.6 The correct producer

consumer algorithm in Section 4.4 allows only n-1 buffers to be

full at any one time. Modify the algorithm to allow all buffers to be utilized fully.

Answer: No answer.

5.1 Provide two program ming examples of multithread ing givi ng improve performa nee over

a sin gle-threaded soluti on.

Answer (1) A Web server that services each request in a separate Lliread. (2) A parallelized

application such as matrix multiplication where different parts of the matrix may be worked on

in parallel. (3) An intEivictin GUI program such as a debugger where a thread is used to

monitor user input, another thread represents the running application, and a third thread

monitors performance.

5.3 What are two differences between user-level threads and kernel-level threads? Under

what circumsta nces is one type better tha n the other?

Answer: Context switching between user threads is quite sinniliir to switching between kernel

threads, although it is dependent on the threads library and how it maps user threads to kernel

threads. In general, context switching between user threads involves taking a user thread of its

LWP and replacing it with another thread. This act typically involves saving and restoring the

stttte of the registers.

6.3 Consider the following set of processes, with the length of the CPU-burst time given in

millisec on ds:

Process Burst

P1

10

Time Priority

3

1

3

4

2

P2

P3

1

2

1

5

F4

P5

The processes are assumed to have arrived in the order

Pl,

F2,

F3,

F4,

P5, all at time 0.

a.

Draw four Gantt charts illustrati ng the executi on of these processes using FCFS, SJF, a non preemptive

priority (a smaller priority n umber implies a higher priority), and RR (qua ntum = 1) scheduli ng.

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)?

An swer:

Answer;

a. The four Gantt charts are

1

2 3 4 5

FCFS

1 2

3 4

5 1 3 5

1

5

】5

]

5 1

RR

7 4

3 5 1

sjr

5 1 3 4

Priority

b. Turnaround time

FCFS

10

11

13

14

19

RR

19

2

7

4

14

SJF

19

1

4

2

9

Priority

16

1

18

19

6

Waiting time (turnaround time minus burst time)

FCFS

卩】

RR

9

1

5

3

9

SJF

9

0

2

1

4

Priority

Pz

P*

Ps

d. Shortest Job First

0

10

11

13

14

6

0

16

18

1

6.4 Suppose that the following processes arrive for execution at the times indicated. Each

process will run the listed amou nt of time. In an sweri ng the questi ons, use non preemptive scheduling and

base all decisions on the information you have at the time the decision

must be made.

PtXKCSS

Ai ri al Time

0.0

Burst Time

8

OS Exercise Book

P2

7

Class

0.4

l.D

No.

4

1

Name

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 performa nee, but no tice 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 un it and the n SJF scheduli ng is used. Remember that processes

and

P2 are wait ing dur ing this idle time, so their wait ing time may in crease. This

algorithm could be known as future-k no wledge scheduli ng.

P1

Answer

a. 10.53

b. 9.53

c. 6,86

Remember that turnaround time

LS finishing time minus arrival time, so have to subtract the

arrival tinier to compute thu turnaround times. FCFS is 11 if you forget to subtract arrival time.

6.10 Explain the differences in the degree to which the following scheduling algorithms discrim in ate in favor of

short processes:

a.

FCFS

b.

RR

c.

Multilevel feedback queues

Answer:

a. FCFS—discriminates against short jobs since any short jobs arriving after long jobs will

have a longer waiting time.

b. RR一

treats all jobs equally (giving them equal bursts of CPU time) so short jobs will be

able to leave the system faster since they will finish first.

c. Multilevel feedback queues—work similar to the RR algorithm—thev discriminate

fa^ri>rably toward slusrt jobs.

7.7 Show that, if the wait and sig nal operati ons are not executed atomically,

then mutual exclusi on may be violated.

Answer No answer.

7.8 The Sleepi ng-Barber Problem. A barbershop con sists of a wait ing 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 en ters the barbershop and all chairs are occupied,

then the customer leaves the shop .If the barber is busy but chairs are available, the n

the customer sits in one of the free chairs. If the barber is asleep, the customer wakes up the barber. Write a

program to coord in ate the barber and the customers.

Answer: Please refer to the support ing Web s its for source code solution,

only one single process? Explain your answer. 8.2 Is it possible to have a deadlock involving

Answer Ncx I'his folknvs directly from the hold-and-wait condition.

8.4 Con sider the traffic deadlock depicted in Figure 8.11.

a. Show that the four n ecessary con diti ons for deadlock in deed hold in this example.

b. State a simple rule that will avoid deadlocks in this system.

Answer No answer.

8.13 Con sider the follow ing sn apshot of a system:

Allocati on

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

0

P1

P2

P3

P4

P

An swer the follow ing questi ons using th e ban ker s algorithm:

a.

What is the content of the matrix Need?

b.

Is the system in a safe state?

c.

If a request from process

P1 arrives for (0,4,2,0), can the request be gran ted

immediately?

Answer;

A. Deadlcx^k cannot ixrcur because preemption exists,

b. Yes. A process may never acquire all the resources

needs if they are continuously

preempted by a series of requests such as those of process C.

9.5 Given memory partitions of 100K, 500K, 200K, 300K, and 600K (in order), how would each of the First-fit,

Best-fit, and Worst-fit algorithms place processes of 212K, 417K, 112K,

and 426K (in order)? Which algorithm makes the most efficie nt use of memory?

Answer:

a. First-fit:

b* 212K is put in 500K partition

c. 417K is put in 600K partition

d* 112K is put in 288K partition (new partition 288K = 500K - 212K)

e. 426K must wait

f. Best-fit:

g. 212K is put in 300K partition

OS Exercise Book

9

Class

h. 417K is put in 500K partition

i. 112K is put in 200K partition

j. 426K is put in 600K partition

k. Worst-fit:

L 212K is put in 600K partition

m. 417K is put in 500K partition

n. 112K is put in 388K partition

c 426K must wait

No. Name

In this example, Best-fit turns out to be the bE%t*

9.8 Con sider a logical address space of eight pages of 1024 words each, mapped onto a physical

memory of 32 frames.

a. How many bits are there in the logical address?

b. How many bits are there in the physical address?

Answer

a, ) address: 13 bits

b. Physical address: 15 bits

J

9.16 Con sider the follow ing segme nt table:

Segme nt Base Len gth

0

1

2

3

4

219

2300

90

1327

1952

600

14

100

580

96

What are the physical addresses for the follow ing logical addresses?

a. 0,430

b. 1,10

c. 2,500

d. 3,400

e. 4,112

Answer:

a. 219 + 430 = 649

b. 2300 + 10 = 2510

u ill亡月ed reference, trap ki operating system

d. 1327 -b 400 = 1727

e. illegal reference, trap to operating system

10.2 Assume that you have a page referenee string for a process with

m

frames (initially

all empty). The page refere nee stri ng has len gth

p

with

n

disti net page n umbers occur in

it. For any page-replacement algorithms,

a. What is a lower bou nd on the n umber of page faults?

b. What is an upper bou nd on the n umber of page faults?

Answer:

a* n

b» p

10.11 Con sider the follow ing page refere nee stri ng:

1, 2, 3, 4, 2, 1,5, 6, 2, 1,2, 3, 7, 6, 3, 2, 1, 2, 3, 6.

How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five,

six, or seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault

each.

LRU replaceme nt

FIFO replaceme nt

Optimal replaceme nt

OS Exercise Book

11

Answer

Class

Numbei of frames

1

2

3

4

5

6

7

No.

LRU

Name

FIFO

20

18

15

10

8

7

7

20

18

16

14

10

10

7

Optimal

20

15

11

8

7

7

7

11.7 Expla in the purpose of the ope n and close operati ons.

Answer:

» The o[fen operation informs the system that the named file is about to bect>me active^

* Tlie cluse operation informs the system that the named file)s nt> lunger in active use by the

user who issued the dose operation.

11.9 Give an example of an application in which data in a file should be accessed in the

followi ng order:

a. Seque ntially

b. Ran domly

Answer:

a. Print the

on tent of the file,

b. Print the content of record /. This record can be found using hashing or index techniques.

11.12 Con sider a system that supports 5000 users. Suppose that you want to allow 4990 of these users to be

able to access one file.

a. How would you specify this protection scheme in UNIX?

b. Could you suggest ano ther protecti on scheme that can be used more effectively for this purpose tha n the

scheme provided by UNIX?

Answer:

a. There are twc methods for achieving this:

L Create an access control list with

tlu? names of all 4990 users.

ii. Put these 4990 users in one ^roup and set the group access accordingly. This scheme

cannot always be implemented since user groups are restricted by the system.

b. The universe access information applies to all users unless their name appears in the access-control list with different access permission. With this scheme you simply put the names

of the remaining ten users in the access control list but v让h no access pri ileges

allovcexf

12.1 Consider a file currently consisting of 100 blocks. Assume that the file control block

(and

the index block, in the case of indexed allocation) is already in memory. Calculate how

many disk I/O operations are required for contiguous, linked, and indexed (single-level)

allocati on strategies, if, for one block, the follow ing con diti ons hold. In the

con tiguousallocati on case, assume that there is no room to grow in the beg inning, but there is room to grow in

the end. Assume that the block in formatio n to be added is stored in

memory.

a. The block is added at the beg inning.

b. The block is added in the middle.

c. The block is added at the end.

d. The block is removed from the begi nning.

e. The block is removed from the middle.

f. The block is removed from the end.

Answer

a.

b.

d.

e.

f.

201

101

1

198

98

0

Linked

1

52

3

1

52

100

Indexed

1

1

1

0

0

0

13.2 Con sider the follow ing I/O sce narios on a sin gle-user PC.

a. A mouse used with a graphical user in terface

b. A tape drive on a multitasking operating system (assume no device preallocation is available)

c. A disk drive containing user files

d. A graphics card with direct bus conn ecti on, accessible through memory-mapped

I/O

For each of these I/O scenarios, would you design the operating system to use buffering, spooli ng, cachi ng, or

a comb in ati on? Would you use polled I/O, or in terrupt-drive n I/O? Give reas ons for your choices.

Answer:

a. A mouse used with a graphical user interface

Buffering may be needed to record mouse movement during times when higher- priority

operations are taking place. Spooling and caching are inappropriate. Interrupt driven I/O is

most appropriate^

b” A tape drive on a multitasking operating system (assume no device preAlkxzation is

available)

Buffering may be needed to manage throughput d让ferEria? behveen the tape drive and

the sounzt? or destination of the I/O, C臼匚hing can be used to hold copies of that resides

on the tape, for faster access. Spooling could be used to stage data to the device when

multiple users desire to read from or write to it” Interrupt driven [/O is likely to allow the

best performance.

OS Exercise Book

13

Class

匸*

No. Name

A disk drive containing user tiles

Buffering can be used to hold data while in transit from user space to the disk, and visa

versa. Caching can be used to hold disk-resident data for improved performance.

Spoc^ling is not necessary because disks are shared-access devices. Interrupt- driven T/O

is best for devices such as disks that transfer data at slow rates,

d. A graphics card w让h direct bus coi^nection, accessible through mem

Buffering may be needed to control multiple access and for performance (doublebuffering

can be used to hold the next screen image while displaying the current tme). Caching and

spooling are not necessaryr due to the fast and shared-access natures of the device. Polling

and interrupts are only useful for input and for【/O completion detectionf neither of which

is needed for a mem()ry-mapped device.

14.2 Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a

request at cylinder 143, and the previous request was at cylinder 125. The queue of pending requests, in FIFO

order, is

86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130

Start ing from the curre nt head positi on, what is the total dista nee (in cyli nders) that

the disk arm moves to satisfy all the pending requests, for each of the follow ing

diskscheduli ng

algorithms?

a. FCFS

b. SSTF

c. SCAN

d. LOOK

e. C-SCAN

Answer:

The FCFS schedule is 143f 86f 1470, 913, 1774, 948, 1509, 1022, 1754), 130. The total seek

distance is 7081.

b. The SSTF schedule is 143, 130, 86. 913, 948, 1022, 1470, 1509. 1750r 1774. The total seek

distance is 1745.

€. The SCAN schedule is 143, 913, 94«f 1022f 1470, 1509,1750f 1774, 4999,130, 86. The to怙

1 seek distance is 9769.

d. The LOOK schedule is 143, 913, 948,1022, 1470,1509,1750,177< 130,86. The total seek

distance is 3319*

e. The C-SCAN schedule is 143f 913,948,1022J 470,1509.1750,1774,4999,8& 130. The total

seek distance is 9813.

f. (Bonus.) The C-LOOK schedule is 143,913,94& 1022,1470,1509.1750,1774, 86,130. The

total seek distance is 3363.

1.1 1.6 2.3 2.5 3.7 6.3 6。4 7.8 8.13 9.5 9.8 10.11 12.1 14.2


本文发布于:2024-09-21 18:55:54,感谢您对本站的认可!

本文链接:https://www.17tex.com/fanyi/24502.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:个人主页   网站   制作   作者
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议