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.

160 Transput Chapter 5language. Their instructions are called commands. Sequences of commands are calledchannel programs and are stored in the same main store used by the cpu. Typical channelscan take channel programs containing more than one command; this facility is calledcommand chaining. In addition, they can often gather output data from various placesor scatter input data to various places in main store. This facility is called data chainingor scatter-gather. DMA is universally available with channels.The cpu sets up the program and then tells the channel to start running it. Whenthe channel program is finished, the channel indicates that fact by setting a bit in a statusregister or by interrupting the cpu. While the channel program is running, the cpu caninvestigate its status and halt it if something has gone wrong.Channels come in various levels of sophistication. A selector channel can managemany devices, but only one may be transferring data at one time. A multiplexor channelcan manage many devices, all simultaneously active.Processes use virtual addresses, while the channel deals with physical addresses.Therefore, if the operating system wishes to let processes submit their own channel programs,the kernel must translate the addresses in each such program before it is given tothe channel.3 DEVICE DRIVERSThe bewildering variety and number of devices for computers is one of the severest challengesof the operating system writer. Each brand of disk, channel, tape, or communicationdevice has its own control protocol, and new devices come on the market with greatfrequency. It is essential to reduce this variety to some sort of order; otherwise, everytime a new device is attached to the computer, the operating system will have to be completelyreworked. Forcing a regular structure, at least at some level inside the kernel,works across a wide range of devices. The device-specific parts of device control canthen be sequestered into well-defined modules.The Unix operating system sets a good example of forcing order on the chaos ofdevice types. Each device can be described by two numbers: the type (each differentbrand of tape drive is usually a different type) and the instance (each separate drive of thesame type has its own instance number). Each type is associated with a device driverthat accommodates the peculiarities of that device type. The device driver for a giventype maintains separate data structures for each instance.Device drivers provide a standard interface to the rest of the kernel. They provideroutines for opening and closing the device (used by the kernel when a process wants tostart or stop using the device) as well as routines for transmitting data to or from the device.Only a few data formats are used, so that the device driver knows what to expect.For example, data may be transmitted in fixed-size blocks, with a standard header. Thisheader might include the following information.device typedevice number

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

Saved successfully!

Ooh no, something went wrong!