[CS61C FA20] Lecture 31.4 - I/O: DMA — Transcript
Full transcript
- 0:00[Music]
- 0:10hello
- 0:11and welcome back to our discussion about
- 0:14input output so we have seen two
- 0:16mechanisms
- 0:17for working with input output devices so
- 0:20far
- 0:22we have seen polling of
- 0:26io devices and interrupts
- 0:29interrupts are actually being
- 0:31practically used for the devices that
- 0:33don't generate a lot of data and don't
- 0:36consume a lot of data
- 0:38those that consume a lot of data
- 0:42are generally nowadays based on
- 0:46direct memory access so that's a
- 0:48different mechanism
- 0:50and let's introduce it here so far
- 0:54the only device that was able to control
- 0:57data transfers to the main memory was
- 1:00the processor itself
- 1:03in order to offload the processor so it
- 1:05doesn't spend
- 1:06a lot of time handling these loads and
- 1:09stores
- 1:10we need to come up with a new device
- 1:13that is new piece of hardware that is
- 1:15going to
- 1:16help processor move large chunks of data
- 1:20to and from the main memory
- 1:25so that dma engine
- 1:28is may exist on the same
- 1:32die as our processor but it will
- 1:37operate it will take control over the
- 1:40memory channels
- 1:42under supervision from the cpu
- 1:45so essentially what is going to happen
- 1:47here is the dma engine
- 1:49will work independently it has
- 1:52some registers that are written by the
- 1:55cpu
- 1:56you know perhaps memory mapped
- 2:00and these registers are going to contain
- 2:03the memory addresses to place the data
- 2:08the number of bytes to be transferred
- 2:11the number of the i o device that is
- 2:13supposed to do that
- 2:14direction of the transfer to the memory
- 2:17on or from the memory
- 2:19and the units of transfer and how much
- 2:24should it do per burst because it can do
- 2:26multiple
- 2:27bursts of certain duration
- 2:31uh per transfer so to illustrate how
- 2:34does that work here is a picture
- 2:37from a textbook that we can use so
- 2:41the cpu is the one that will initiate
- 2:44the transfer whether it is going to the
- 2:46memory or from the memory it will write
- 2:48the address the count and control bits
- 2:52into the dma controller
- 2:56in turn the
- 3:00dma will request transfer to the memory
- 3:04uh from the device perhaps you know
- 3:06somebody who
- 3:07generally is has plenty of data to move
- 3:10around
- 3:11is the disk or this controller that may
- 3:14be controlling multiple disks
- 3:16so disks modern disks generally have
- 3:20buffers and
- 3:21they can read ahead and buffer some
- 3:24amount of data and non-negligible amount
- 3:26of data
- 3:27on them so dma engine is going to
- 3:30tell it basically to transfer the
- 3:32contents of its buffer
- 3:34to a particular location in the memory
- 3:36that has been specified
- 3:38by the cpu when it is done
- 3:43with the transfer it'll sell
- 3:47this controller will send an
- 3:48acknowledgement to a dma engine
- 3:50and dma engine will interrupt the cpu to
- 3:54tell
- 3:54that it is done that that file has been
- 3:57moved
- 3:58and the transfer has been completed so
- 4:03the cpu gets interrupted only twice
- 4:06first
- 4:07to start the transfer
- 4:10then the transfer may be long we may be
- 4:13moving megabytes or gigabytes of
- 4:15of data which is what i generally do
- 4:17with
- 4:18when moving these videos back and forth
- 4:22and then you know while the data is
- 4:26moving the cpu can do something else
- 4:28and then when it's done it gets
- 4:29interrupted again to
- 4:31just know that the file
- 4:35movement has completed
- 4:38all right let's you know step through
- 4:41that
- 4:42for the incoming direction of the data
- 4:46so the processor will receive
- 4:49the interrupt from the device uh it
- 4:52would take the interrupt
- 4:53and um through a trap handler
- 4:58it would initiate the transfer it would
- 5:00instruct the dma
- 5:02engine to place data at certain
- 5:05addresses
- 5:06in the memory the
- 5:09device and the dma engine are going to
- 5:11handle the transfer themselves
- 5:13cpu is free to continue executing a
- 5:16program it returns from the interrupt
- 5:18and continues doing whatever it has been
- 5:19doing
- 5:20upon completion completion the device
- 5:23the disk
- 5:24in this case and the dm engine interrupt
- 5:28the cpu again
- 5:29generally the device interrupts
- 5:32acknowledges to the
- 5:36dma controller and dma controller
- 5:38interrupts the
- 5:40the cpu to tell that is is done
- 5:44in the outgoing direction of the data if
- 5:47cpu
- 5:48has something that would like to move
- 5:51from
- 5:52memory to an external device it
- 5:55initiates the transfer first it confirms
- 5:58that
- 5:59the device is ready by reading its
- 6:03control register and then begins the
- 6:06transfer
- 6:08probably more properly we would say here
- 6:11initiates the transfer it instructs the
- 6:13dma engine
- 6:14um to work with the device
- 6:18that to tell it that the data is
- 6:20available at a certain address in the
- 6:22memory
- 6:23and then um the the
- 6:26dma is going to work with the device say
- 6:29a disk
- 6:30to handle the transfer cpu does whatever
- 6:33it
- 6:34wanted to do next and the device
- 6:38acknowledges that it has received the
- 6:40data to the dme
- 6:41dma engine which interrupts the cpu
- 6:45to signal the completion that is it that
- 6:48sounds
- 6:49fairly simple and cool these things did
- 6:52you know we mentioned that we had
- 6:55programmed io as
- 6:56a mode operation say in the 90s
- 7:00with 88 disks dma has replaced that
- 7:04in 2000s and most of the disks nowadays
- 7:07or all of this nowadays
- 7:09do support dma transfers
- 7:13but there are some other problems these
- 7:15dma
- 7:17controllers that share the the
- 7:20chip area with the processor we have
- 7:23freedom where we would like to to to
- 7:25plug them in
- 7:27so where do we want to put our dma
- 7:29controller in the memory hierarchy
- 7:31well there are two extremes and many
- 7:33other variants
- 7:34first we can put it between the cpu and
- 7:37l1 cache so we can plug it in right
- 7:40there
- 7:41[Music]
- 7:42if we do that we got free coherency
- 7:45meaning the processor memory system
- 7:48cache system is going to handle the
- 7:49coherency
- 7:53the problem here is that every time we
- 7:55initiate a dma
- 7:57may transfer we're going to trash the
- 7:59cpu's working set
- 8:01with transfer data the other option is
- 8:05to put it between the last level cache
- 8:07and the main memory
- 8:09so we don't miss processor caches
- 8:11processor
- 8:12on the interrupt can just after handling
- 8:15an interrupt can
- 8:16resume what it was doing but
- 8:20the challenge here is that we
- 8:24need to implement a new coherency engine
- 8:27and that is usually what is being done
- 8:30somehow the dma
- 8:31has to work with a key
- 8:35with a coherency engine to support it
- 8:40that's it for the dma and for generally
- 8:44handling i o devices just one more quick
- 8:47example is coming up
- 8:49and then we are done with this module
- 8:52see you after a quick break
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 31.4 - I/O: DMA by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,098 words across 206 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.