程序代写代做代考 cache C502 – Operating Systems Tutorial ∗

C502 – Operating Systems Tutorial ∗

Device Management

1. In which of the four I/O software layers (user-level I/O software, device-independent OS software,
device drivers and interrupt handlers) is each of the following done?

(a) Computing the track, sector and head for a disk read

(b) Maintaining a cache of recently used blocks

(c) Writing commands to the drive registers

(d) Checking to see if the user is permitted to use the device

(e) Converting binary integers to ASCII for printing

2. Explain what direct memory access (DMA) is and why it is used. Although DMA does not use the
CPU, the maximum transfer rate is still limited. Consider reading a block from disk. Name three
factors that might ultimately limit the rate of transfer. (Exam question 2015-16).

3. What is spooling? Why is a printer spooling system better than direct user access to printers?

4. An operating system has to support I/O devices with very diverse properties. Complete the following
table, as exemplified below, using your best guesses.

Device Type (Character/Block) Operation (Read, Write, Seek)

Clock

Keyboard

Mouse

56k Modem C R, W

ISDN line

Laser Printer

Scanner

52x CD-ROM

FastEthernet

EIDE (ATA-2)disk

ISA bus

Fire Wire (IEEE 1394)

USB 2.0

XGA Monitor

Gigabit Ethernet

Serial ATA disk

SCSI Ultrawide4 disk

PCI bus

5. Write a C program that implements the copy (cp) command. Your program should be invoked as:

mycp

∗with thanks to Morris Sloman

(a) Make sure that you use the correct Linux I/O calls. How efficient is your implementation compared
to the standard cp command? You can use the time command to measure execution times for
various file sizes. If there is a performance difference, can you explain it?

(b) The strace command can be used to trace the system calls that a program makes. Compare the
system calls between cp and mycp. Again, can you explain the differences?

2