13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The process interface 173device for the stated intent. We will discuss access control in Chapter 6 when wetalk about files. The result of this call is a device descriptor, which the processwill use to refer to the device in other service calls.Close(device descriptor). This call tells the device driver that the process isfinished with the device and that it can be used now by some other process.Device-specific finalization will be performed. For a tape, this finalization mighttake the form of rewinding and unloading the tape and printing a message for theoperator to dismount the tape.Position(device descriptor, where). This call tells the device driver to positionthe device to a particular location. For example, a tape may be advanced onerecord or one file in this way. Likewise, a disk may be set to read at a particularsurface, track, and sector. In the absence of Position calls, the device might moveto the ‘‘next’’ location after each Read and Write.Read(device descriptor, virtual address, amount). This call causes the devicedriver to transfer data from the device to the virtual address given in the process.If the device does not have the desired number of bytes available (for example, theuser types ‘‘end of transmission’’ into a terminal before the requested number ofbytes has been entered, or the end of a file or tape record is reached), fewer bytesmay be read.Write(device descriptor, virtual address, amount). This call causes the devicedriver to transfer data from the process to the device.Control(device descriptor, code). This call performs other actions that do not fitinto the file metaphor, such as setting the density of the tape drive or the echocharacteristics of a terminal.Figure 5.12 shows how these calls fit into our picture of an operating system.5.1 To block or not to blockThe most far-reaching choice is whether transfer should cause the process to block ornot. A blocking transfer is called synchronous because when the process next executes,it can assume that the data have been transferred. The alternative is asynchronousprocessesopen close position read write controlkernelprocess interfacedevicesFigure 5.12 The process interface

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!