Information Technology Reference
In-Depth Information
Advanced DMA
Although a setting up a device's DMA can be as simple as providing a target physical
address and length and then saying “go!”, more sophisticated interfaces are increasingly
used.
For example rather than giving devices direct access to the machine's physical ad-
dress space, some systems include an I/O memory management unit (IOMMU) that
translates device virtual addresses to main memory physical addresses similar to how
a processor's TLB translates processor virtual addresses to main memory physical ad-
dresses. An IOMMU can provide both protection (e.g., preventing a buggy IO device
from overwriting arbitrary memory) and simpler abstractions (e.g., allowing devices to
use virtual addresses so that, for example, a long transfer can be made to a range of
consecutive virtual pages rather than a collection of physical pages scattered across
memory.)
Also, some devices add a level of indirection so that they can interrupt the CPU less
often. For example, rather than using memory mapped I/O to set up each DMA request,
the CPU and I/O device could share two lists in memory: one list of pending I/O requests
and another of completed I/O requests. Then, the CPU could set up dozens of disk
requests and only be interrupted when all of them are done.
Sophisticated I/O devices can even be configured to take different actions depending
the data they receive. For example, some high performance network interfaces parse
incoming packets and direct interrupts to different processors based on the network
connection to which a received packet belongs.
events.
11.3.4
Putting it all together: A simple disk request
When a process issues a system call like read() to read data from disk into
the process's memory, the operating system moves the calling thread to a wait
queue. Then, the operating system uses memory mapped I/O both to tell the
disk to read the requested data and to set up DMA so that the disk can place
that data in the kernel's memory. The disk then reads the data and DMAs it into
main memory; once that is done, the disk triggers an interrupt. The operating
system's interrupt handler then copies the data from the kernel's buer into
the process's address space. Finally, the operating system moves the thread the
ready list. When the thread next runs, it will returns from the system call with
the data now present in the specified buffer.
Exercises
5. Write a program that times how long it takes to issue 100,000 one-byte
Search WWH ::




Custom Search