I/O Devices

CSCI 333 : Storage Systems

Spring 2021

Background

This unit assumes you know a few concepts that are covered elsewhere. In particular, you should be able to answer the following questions at a high level:

For more details about processes, you can check out Chapter 13.2 of the Dive Into Systems textbook.

I/O Devices

At some point, all persistent data is eventually stored on some I/O device. (There are many types of devices, but in this course we will focus on storage devices, like hard disk drives (HDDs) or solid state drives (SSDs).)

Devices can connect to the CPU using a variety of physical interfaces, each with different bandwidth limits. At a high level, we want to reserve the fastest buses for the devices that can fully utilize their available bandwidth—physical space on the motherboard and proximity to the CPU makes the highest-speed buses a scarce resource.

Our OS code chooses among several strategies when interacting with devices. The goal of this chapter is to understand the landscape of choices.

Connections/Interfaces

Different elements of the memory hierarchy are connected to the CPU using different physical interfaces. The physical interfaces often support different software interfaces (commands) for communicating with the devices and/or have different maximum throughputs.

Connections Questions

Devices

Every device exports some hardware interface, which describes a format/protocol that the OS may use to communicate with it. Devices also have their own internal structures: for example, some devices have their own CPUs and memory inside them, some have moving parts, etc.

Firmware the term for software that runs inside a device. Storage device firmware manages the internal physical hardware and implements the hardware interface. Actual firmware details are often hidden from device users (in other words, firmware code is often proprietary and closed-source), and firmware is often fixed (in other words, once you buy a device you can’t update its firmware).

Device Questions

Interacting with Devices

The hardware interface gives the OS a vocabulary to use when communicating with a device, but it doesn’t define an algorithm for “structuring the conversation”. There are two important techniques that the OS uses when conversing with device: polling and interrupts.

One goal we should keep in mind when communicating with a device is to maximize the utilization of hardware. This can be challenging. In order to communicate with a storage device, we often need to copy large amounts of memory to and from the device, and this is a task that might fall on the CPU. Copying memory is not exactly the best way to spend the CPU’s cycles because it is such a straightforward task: all you need to know is a source address, a destination address, and how much memory to copy. Instead of wasting CPU cycles on this trivial task, we would ideally offload this work.

Polling vs. Interrupt Questions

Device Drivers

To keep the OS code as general as possible, device drivers occupy the lowest level of the Linux software storage stack. There are advantages and disadvantages to an OS designed in this way.

Device Driver Questions

If you look at the Linux software stack diagram (OSTEP figure 36.4, 9th page of chapter 36), file systems sit above the generic block layer, and device drivers sit below the generic block layer.