[CS61C FA20] Lecture 31.3 - I/O: I/O Interrupts — Transcript
Full transcript
- 0:00[Music]
- 0:10hello
- 0:10and welcome back to our discussion about
- 0:13input output devices
- 0:14we have introduced polling as one way to
- 0:18work with input devices but it is
- 0:20generally
- 0:21inefficient especially with those that
- 0:24have a lot of data to
- 0:26transmit or receive it is
- 0:29a valid technique and i certainly have
- 0:32used it
- 0:33in the past myself um particularly when
- 0:36doing some prototyping when for example
- 0:39have a raspberry pi i would like to
- 0:41figure out if
- 0:42some new i o device is working properly
- 0:46the easiest thing that we can do is to
- 0:49set up a
- 0:50very short polling loop and see
- 0:53what does the device do more commonly
- 0:56the way how we are going to work with
- 0:58io devices is through unknown mechanism
- 1:01of interrupts
- 1:02so we have already highlighted that
- 1:05polling waste processor resources why
- 1:08well simply because whether the
- 1:10input output device has something to
- 1:12tell us um
- 1:14or not we anyways go to it and check how
- 1:18is it doing if it has no data for us we
- 1:21still spend processor cycles to go pull
- 1:24it
- 1:26and there is an analogy in real life you
- 1:28know when we throw a party
- 1:29um this wood polling would be equivalent
- 1:32to
- 1:33setting a timer and going to the front
- 1:35door every minute to check if somebody
- 1:37has arrived we don't do that because
- 1:40people long time ago have
- 1:41invented a doorbell to exactly prevent
- 1:44us from doing that so when the guests
- 1:47arrive
- 1:48they ring the doorbell to announce
- 1:50themselves
- 1:51similarly an io device rings their
- 1:54doorbell
- 1:55when they have something to tell us
- 1:57their doorbell
- 1:58is the interrupt so they will raise an
- 2:02interrupt or throw an interrupt
- 2:04whenever they have some data to deliver
- 2:06us or perhaps if
- 2:08there is some some event that they would
- 2:10like to tell us about
- 2:15so the interrupt will
- 2:18interrupt the current program and then
- 2:21we will transfer
- 2:22the control to the trap handler in the
- 2:25operating system
- 2:26that will handle that interrupt
- 2:30um why interrupt surprising polling
- 2:33because when nothing is happening
- 2:36no news from the i o device there is
- 2:38nothing to do
- 2:39our regular program continues
- 2:44if there are if the device is not
- 2:46producing a lot of data
- 2:48and doesn't have a lot of activity it's
- 2:50great because we just periodically
- 2:52will receive these interrupts and handle
- 2:55them
- 2:56accordingly but if the device has
- 2:59a lot of io interrupts are expensive
- 3:03because
- 3:04they interrupt the current programs
- 3:06trash the caches uh
- 3:08trash the tlbs and we have to go save
- 3:11the straight
- 3:12save the state restore the state and
- 3:14then you know warm up caches
- 3:16and so on so they're not the best thing
- 3:19to do generally
- 3:22they are fine for low rate devices and
- 3:26they're preferred to polling
- 3:27so my keyboard and so on will use
- 3:30interrupts
- 3:36the in devices that produce a lot of
- 3:40data
- 3:41a more common way is that they will
- 3:44initiate the data transfer with an
- 3:46interrupt when they have something to
- 3:48send us
- 3:48receive the packet over wi-fi
- 3:51but the transfers are generally if there
- 3:55is a lot of data to be transferred
- 3:56it is done by using a different
- 3:59mechanism
- 4:01so-called direct memory access or dma
- 4:04which we'll cover
- 4:05in the next section before we get to the
- 4:07next section
- 4:08there is an older way of essentially
- 4:11orchestrated polling which is it which
- 4:14was known as programmed io
- 4:17or po this
- 4:20was introduced with older ata
- 4:23style hard drives probably you do not
- 4:26have an
- 4:26ata star uh kind of a hard drive
- 4:30where essentially it was the role of a
- 4:33processor
- 4:35that to to initiate
- 4:38all the data movement to and from the
- 4:41hard drive
- 4:42it was done in a more efficient way than
- 4:44just using loads and stores
- 4:46but loads and stores initiated that
- 4:50so this cpu was typically spending some
- 4:53number of its cycles to get the data
- 4:57to and from the disk
- 5:00and into the main memory but
- 5:03that was the same cpu that was
- 5:06being used to do the main computation so
- 5:10handling the disk was an overhead
- 5:12typically what would go
- 5:14to programmed io were about five percent
- 5:18of processor cycles
- 5:23so these kind of things happen still
- 5:26there are still instructions in big
- 5:29processors that
- 5:30are being dealt that are being used to
- 5:32copy
- 5:33a piece of data from one location to
- 5:36another
- 5:37for example if you look at google's uh
- 5:40workload they report that about five
- 5:42percent of cpu cycles
- 5:44go to instructions like mem
- 5:47copy which copies from one memory
- 5:49location
- 5:50to another
- 5:54we're going to see some other
- 5:57methods like the dma access
- 6:01just after the break and we'll use them
- 6:03whenever we can
- 6:04when we have a lot of data to move
- 6:06around see you after a quick break
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 31.3 - I/O: I/O Interrupts by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 802 words across 149 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.