UPI Study › Courses › Introduction to Operating Systems › Free lessons › Lesson 5.5 Free with a free account
Device Access Methods
Introduction to Operating Systems · Chapter 5: Peripheral Devices and I/O SystemsSection 5.5 · lesson 40 of 838 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Introduction to Operating Systems.
Lesson complete
Earn the 3 college credits for Introduction to Operating Systems
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: How Devices Communicate →← Classifying Peripheral DevicesNext lesson: How Devices Communicate →
A free account plays all of Chapter 1 and 3 more lessons of Introduction to Operating Systems. Create a free account →
In this lesson
Polling, interrupts and DMA, plus memory-mapped and port-mapped I/O.
- Compare polling, interrupt-driven I/O and DMA by the CPU time they use
- Choose a suitable access method for a given device and workload
- Distinguish memory-mapped I/O from port-mapped I/O
- Explain why naming a device and waiting for it are separate choices
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (1,113 words). Read along, or search it.
Opening Analogy
Three Ways to Wait for an Oven
Sam, who runs a small online bakery, is waiting for the oven timer, while also answering the shop's phone. One way to wait: stand in front of the oven, and stare at it until it rings. Another: carry on with other work, and let the timer interrupt. A third: ask a helper to watch the oven, and shout only when all the trays are done. A computer faces the same three choices every time it talks to a slow device. And the choice decides how much of the processor's time is wasted.
Programmed I/O
Polling Keeps the CPU Asking
Peripherals are far slower than the processor. Even a drive takes ages to deliver its next byte, compared with how fast the CPU runs instructions. The first method is programmed I/O, also called polling. The CPU runs a loop. Is the device ready? No. Is it ready now? No. Now? Yes! Then it moves one byte, and starts asking again. Polling is simple, needs no special hardware, and answers instantly once the device is ready. But the CPU is busy for the whole transfer. While it waits, nothing else gets done.
Interrupt-Driven I/O
Let the Device Signal When Ready
The second method is interrupt-driven I/O. The CPU starts the device, and goes back to other work. When the device is ready, it sends an interrupt: a signal on the control bus from lesson 5.3. The CPU pauses, saves its place, runs a short routine called an interrupt handler to move the data, and then returns to what it was doing. Lesson 3.3 showed interrupts in general. Here, they serve devices. Interrupts waste far less waiting time. But they aren't free. Stopping, saving, and resuming cost a little every time. For a device that delivers lots of data, one byte at a time, those costs add up.
Direct Memory Access
A Controller Moves the Whole Block
The third method is direct memory access, or DMA. It hands a whole block transfer to a separate chip, the DMA controller. The CPU only sets up the job: which device, where in memory, and how many bytes. The controller then moves all of it, between the device and RAM, borrowing the bus when it needs to. And it sends a single interrupt at the very end. The CPU is free for the whole transfer, except at the start and the finish. A common mistake is thinking DMA means no CPU at all. The CPU still sets up the transfer, and handles that done interrupt. It's only free during the long middle part.
Toy Model
Busy Ticks for One Hundred Bytes
How much does the choice matter? Here's a toy model: move one hundred bytes from a slow device. The time unit is a tick, invented for this model, so the numbers show a pattern, not a measurement of any real machine. The device delivers one byte every ten ticks, so every method needs at least a thousand ticks. What changes is how many of those ticks the CPU spends busy. Polling keeps the CPU busy for all one thousand ticks, leaving none free. Interrupts cost five ticks per byte, two to copy and three to switch. That's five hundred busy ticks, so half the time is free. DMA costs only eight ticks, at the two ends. Nine hundred ninety-two ticks, about ninety-nine percent, are free for other work.
Rule of Thumb
Matching the Method to the Device
So here's a rule of thumb. Polling suits a device that's almost always ready, or a very short wait. Interrupts suit slow, occasional events, like keystrokes. DMA suits big blocks, like a drive moving thousands of bytes. Real systems mix all three. Sam's order program once froze for a few seconds each time it saved the daily backup. Ivy, who looks after the computers at a school, found that the old drive's driver was copying every byte through the CPU. Switch it to DMA, she said, and the CPU can go on serving customers while the drive copies. After the change, the program kept responding during the save.
Quick Check
An Always-Ready Temperature Sensor
Quick check. Ivy's server room has a temperature sensor. It always has a fresh reading ready, the instant it's asked. The CPU only wants one reading a minute: a couple of bytes. Which method fits best: interrupts, polling, or DMA? Pause, and decide. Polling. The device is always ready, so one quick question gets the answer at once. No waiting loop ever spins. Interrupts are tempting, but they exist so the CPU needn't wait for a slow device. Here there's no wait to avoid, and the stop and save would cost more than the question. And DMA is meant for big blocks, not a couple of bytes.
Naming Devices
Memory-Mapped Versus Port-Mapped I/O
All three methods still need a way for the CPU to name a device. Devices have small storage spots called registers. One holds a status, like ready. Another holds a command, like start. Another holds a byte of data. Two common designs reach them. In memory-mapped I/O, device registers take some addresses from the same address space as RAM. The CPU uses its ordinary load and store instructions, as if they were memory. In port-mapped I/O, also called isolated I/O, devices get a separate address space of ports, reached with special in and out instructions. A signal on the control bus says: this address is a port, not memory.
Processor Families
Naming Is Separate From Waiting
Which design a machine uses depends on its processor family. Intel and AMD chips offer both. ARM chips, like the one in many phones and in recent Macs, use only memory-mapped I/O. With memory-mapped devices, one set of instructions reaches both RAM and devices. The cost is that some of the address space, from lesson 5.3, is used up by device registers. And notice: these two designs are about how the CPU names a device. Polling, interrupts, and DMA are about how it waits, and who moves the data. You can combine any naming scheme with any waiting method.
Quick Check
Ordinary Stores and One Done Interrupt
One more. A driver stores a memory address, and a byte count, into a controller's registers, using ordinary store instructions. Then the CPU runs other programs, until a single done interrupt arrives. Which pair describes this: how it names the device, and how it waits? Pause, and decide. Memory-mapped, with DMA. Ordinary stores reach the registers, so they sit in the memory address space. And a set-up, then other work, then one done interrupt for the whole job, is DMA's signature. The third choice gets the naming right, but polling would keep the CPU asking, with no time for other programs.
Key Takeaways
Polling, Interrupts, DMA and Naming
To recap. Polling keeps the CPU asking, and busy, the whole time. Interrupts free the CPU, but each one costs a stop and a save. DMA hands a whole block to a controller, with one interrupt at the end. And memory-mapped or port-mapped I/O is how the CPU names a device: a separate choice from how it waits.
About Introduction to Operating Systems at UPI Study
Introduction to Operating Systems (Computer Science 354) is a self-paced online course of 83 video lessons in 10 chapters, from what an operating system does and process scheduling to concurrency, memory, devices, file systems, networks, the internet, security and virtual machines. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Compare: Linux vs Operating Systems
Why take it here
Why students take Introduction to Operating Systems with UPI Study
Where the credit goes
Universities that work with NCCRS
Introduction to Operating Systems carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Device Access Methods
What is the difference between polling and interrupts?
How does direct memory access work?
When is polling better than interrupts?
What is the difference between memory-mapped I/O and port-mapped I/O?
About the Introduction to Operating Systems course
How many college credits is Introduction to Operating Systems?
How much does Introduction to Operating Systems cost and what is included?
Which universities accept UPI Study credits?
How long does Introduction to Operating Systems take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Introduction to Operating Systems.
83 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
Updated
3 credits · NCCRSEnroll →