Disk Scheduling and Input/Output Management

Disk Scheduling and Input

INTRODUCTION

In the last chapter we looked at input and output from the way a user or an application programmer would look at it—what are the capabilities and services that the OS provides to the upper layers, what are the data structures needed to perform these services, and how are these functions performed? In this chapter, we look in the lower layers to see how these things are done. In particular, the lowest layer of any file system is a collection of device drivers and interrupt handlers. Disk Scheduling and Input In earlier chapters, we discussed how I/O capabilities started with simple devices and structures and have progressed to more complex systems and services. We take a closer look at modern hardware and the OS organization necessary to manage these devices effectively and economically.

DEVICE CHARACTERISTICS

There are some categories of input/output that broadly divide them into groups that are treated differently by OSs. We discuss a few of those categories.

Random access versus sequential access

In this chapter, we are focused almost exclusively on secondary storage devices, specifically disk drives. At one time magnetic tapes were used for secondary storage on large mainframe computers. When personal computers were first developed they also often had tape drives as the only secondary storage devices, in this case, it was a quarter-inch cassette tape drive that was originally developed for audio use. But tapes have the unfortunate characteristic that they can’t be read randomly. To get to any particular piece of data on the tape you have to pass over all the other data between where the head is now and where it needs to be.

Even on very fast tape drives, this could take several minutes. Fortunately, disk drives don’t have that characteristic. Because of this difference we speak of disk drives as being “random access” devices. However, as we will see when we later look at disk drives in more detail, this does not mean that the time to access the data is independent of the location of the data. This term is merely a reflection of the contrast with using a tape drive as the main secondary storage device.

Device classes

Most OSs broadly divide devices into three classes: block, character, and network. Each of those classes has substantially different characteristics and each class can be abstracted in a meaningful way. Table 14.1 gives some information about these classes.

Block devices

Such devices include all sorts of disk drives and tape drives, for example. Disk Scheduling and Input The size of a block is determined partly by the hardware, since disk controllers can only read or write whole disk sectors, but also by the system administrator when the file system is set up. Normally, the block size will be some small multiple of the physical sector size—typically 4 or 8 KB. These devices often support random access directly to any block on the device, that is to say that blocks may be read or written in any order. File systems typically reside on block devices and are the normal mechanism for accessing these devices. There are caching mechanisms in place for random access block-structured devices. Sequential access block devices use double buffering, as explained later.

Occasionally, some software needs to access these block devices directly rather than by using the file system. This is called a raw I/O. Disk Scheduling and Input Examples of such software include utilities for maintaining or examining the file system itself (e.g., fsck for Linux and UNIX) and software that places extraordinary demands on the secondary storage and is sophisticated enough to include a preferred mechanism for caching or for scheduling disk operations (e.g., very demanding database servers).

Character devices

They include printers, keyboards, mice (and other pointing devices), and so on. They support most of the same basic kinds of operations as a block model file: open, close, read, and write. To perform an operation that doesn’t fit the semantics of the file system model (e.g., reading the status of a printer), a program can use the ioctl system call. Disk Scheduling and Input Character mode devices obviously cannot support seeking backwards. For example, one cannot read the character typed on the keyboard 20 characters previously, or a character printed on the previous page. Some character devices will allow skipping characters in a forward direction. Character mode devices are never cached, though they may have a buffer.

Leave a Reply

Your email address will not be published. Required fields are marked *