• 沒有找到結果。

What would be a marketable price for the optical tape if the magnetic

Mass Storage Structure

Exercises 91 What would be a marketable price for the optical tape if the magnetic

tape cost $25?

Answer: The area of a 5.25 inch disk is about 19.625 square inches.

If we suppose that the diameter of the spindle hub is 1.5 inches, the hub occupies an area of about 1.77 square inches, leaving 17.86 square inches for data storage. Therefore, we estimate the storage capacity of the optical disk to be 2.2 gigabytes.

The surface area of the tape is 10,800 square inches, so its storage capacity is about 26 gigabytes.

If the 10,800 square inches of tape had a storage density of 1 gigabit per square inch, the capacity of the tape would be about 1,350 gigabytes, or 1.3 terabytes. If we charge the same price per gigabyte for the optical tape as for magnetic tape, the optical tape cartridge would cost about 50 times more than the magnetic tape, i.e., $1,250.

12.22 Discuss how an operating system could maintain a free-space list for a tape-resident file system. Assume that the tape technology is append-only, and that it uses theEOTmark andlocate,space, andread position commands as described in Section 12.9.2.1.

Answer: Since this tape technology is append-only, all the free space is at the end of the tape. The location of this free space does not need to be stored at all, because thespace command can be used to position to theEOTmark. The amount of available free space after theEOTmark can be represented by a single number. It may be desirable to maintain a second number to represent the amount of space occupied by files that have been logically deleted (but their space has not been reclaimed since the tape is append-only) so that we can decide when it would pay to copy the nondeleted files to a new tape in order to reclaim the old tape for reuse. We can store the free and deleted space numbers on disk for easy access. Another copy of these numbers can be stored at the end of the tape as the last data block. We can overwrite this last data block when we allocate new storage on the tape.

13

C H A P T E R

I/O Systems

The role of the operating system in computerI/Ois to manage and controlI/O operations andI/Odevices. Although related topics appear in other chapters, here we bring together the pieces to paint a complete picture. In this chapter we describe I/O Structure, Devices, Device Drivers, Caching, and Terminal I/O.

Exercises

13.1 When multiple interrupts from different devices appear at about the same time, a priority scheme could be used to determine the order in which the interrupts would be serviced. Discuss what issues need to be considered in assigning priorities to different interrupts.

Answer: A number of issues need to be considered in order to deter-mine the priority scheme to be used to deterdeter-mine the order in which the interrupts need to be serviced. First, interrupts raised by devices should be given higher priority than traps generated by the user program; a device interrupt can therefore interrupt code used for handling system calls. Second, interrupts that control devices might be given higher pri-ority than interrupts that simply perform tasks such as copying data served up a device to user/kernel buffers, since such tasks can always be delayed. Third, devices that have realtime constraints on when its data is handled should be given higher priority than other devices.

Also, devices that do not have any form of buffering for its data would have to be assigned higher priority since the data could be available only for a short period of time.

13.2 What are the advantages and disadvantages of supporting memory-mappedI/Oto device control registers?

Answer: The advantage of supporting memory-mappedI/Oto device control registers is that it eliminates the need for specialI/O instruc-tions from the instruction set and therefore also does not require the enforcement of protection rules that prevent user programs from ex-93

ecuting theseI/O instructions. The disadvantage is that the resulting flexibility needs to be handled with care; the memory translation units need to ensure that the memory addresses associated with the device control registers are not accessible by user programs in order to ensure protection.

13.3 Consider the followingI/Oscenarios on a single-userPC. a. A mouse used with a graphical user interface

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 connection, accessible through memory-mappedI/O

For each of theseI/Oscenarios, would you design the operating system to use buffering, spooling, caching, or a combination? Would you use polledI/O, or interrupt-drivenI/O? Give reasons 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. Spool-ing and cachSpool-ing are inappropriate. Interrupt drivenI/Ois most appropriate.

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

Buffering may be needed to manage throughput difference be-tween the tape drive and the source or destination of the I/O, Caching can be used to hold copies of data 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 drivenI/Ois likely to allow the best performance.

c. A disk drive containing user files

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. Spooling is not necessary because disks are shared-access devices. Interrupt-driven I/O is best for devices such as disks that transfer data at slow rates.

d. A graphics card with direct bus connection, accessible through memory-mappedI/O

Buffering may be needed to control multiple access and for per-formance (double-buffering can be used to hold the next screen image while displaying the current one). Caching and spooling are not necessary due to the fast and shared-access natures of the device. Polling and interrupts are only useful for input and for I/O completion detection, neither of which is needed for a memory-mapped device.

Exercises 95