In direct memory access (DMA) based input or output, what is cycle stealing and how does it affect the CPU?

Difficulty: Medium

Correct Answer: A technique where the DMA controller temporarily takes control of the system bus for a memory cycle to transfer data, effectively borrowing cycles that the CPU would otherwise use

Explanation:


Introduction / Context:
Direct memory access allows devices to transfer data between memory and peripherals without constantly involving the CPU in each word or byte transfer. To do this, the DMA controller must use the system bus, which is also needed by the CPU. Cycle stealing is a mechanism that coordinates these shared bus accesses. Understanding cycle stealing helps explain performance trade offs in DMA based input or output.


Given Data / Assumptions:

  • Both the CPU and the DMA controller need to access main memory through a shared system bus.
  • DMA is used to transfer large blocks of data efficiently.
  • The CPU can tolerate brief pauses in memory access without significant functional impact.


Concept / Approach:
Cycle stealing occurs when the DMA controller temporarily gains control of the system bus for one or more memory cycles in order to move data between a device and main memory. During these cycles, the CPU is prevented from accessing memory and must wait, effectively giving up those cycles to the DMA controller. From the CPU perspective, these are cycles that could have been used for instruction execution but are instead used for DMA transfers. The term stealing reflects this borrowing of bus usage. However, because the transfers are efficient and typically occur in bursts, overall system throughput can still improve compared with CPU driven programmed input or output.


Step-by-Step Solution:
Step 1: Recall that DMA controllers transfer data directly between devices and memory without CPU intervention for each word.Step 2: Understand that to read or write memory, the DMA controller must use the system bus, which is the same bus used by the CPU.Step 3: During a DMA memory cycle, the DMA controller takes priority, and the CPU is temporarily blocked from accessing memory.Step 4: These memory cycles, which would otherwise be available for CPU fetch or data access, are thus said to be stolen by the DMA controller.Step 5: Choose the option that describes this temporary transfer of bus control and memory cycles from the CPU to the DMA controller.


Verification / Alternative check:
Hardware descriptions of DMA operation explain that some systems use burst mode DMA, where the controller transfers a block of data while the CPU is stopped, and others use cycle stealing mode, where the CPU runs but is occasionally paused for single cycles while DMA transfers occur. Performance analyses show that while the CPU loses some cycles, overall input or output throughput improves and CPU overhead decreases compared with program controlled input or output loops.


Why Other Options Are Wrong:
Option B: Describes a security attack related to scheduling, which is unrelated to the hardware level concept of cycle stealing in DMA.Option C: Talks about permanently disabling CPU cycles for power saving, which does not match the temporary borrowing of bus cycles during DMA.Option D: Mentions file system operations without main memory, which does not correspond to how DMA and cycle stealing work.


Common Pitfalls:
Students sometimes interpret cycle stealing as something negative or malicious because of the word stealing. In reality, it is a planned and controlled part of system design. Another confusion is to think that the CPU cannot do any work while DMA is operating. In cycle stealing mode, the CPU continues executing instructions whenever it does not need memory, and only stalls briefly when a stolen cycle occurs.


Final Answer:
The correct answer is A technique where the DMA controller temporarily takes control of the system bus for a memory cycle to transfer data, effectively borrowing cycles that the CPU would otherwise use.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion