- 2068 Magh · 3+5 marks
Device controller vs kernel; DMA
Short answer
Placing functions in the controller offers faster operation, reduced CPU load, and simpler kernel, but is less flexible, costlier, and harder to debug. DMA transfers data directly between device and memory using an address/count controller, stealing bus cycles, and interrupts only after the block, freeing the CPU and reducing interrupts.
State the advantages and disadvantages of placing the functionality in a device controller than in kernel. Explain in detail about DMA.
Placing functionality in the device controller instead of the kernel
A device controller is the electronic unit (with its own processor and memory) that operates a device; the kernel (device driver) is software on the main CPU.
Advantages
- Faster operation: done in hardware/firmware and in parallel with the CPU, so the CPU is free for other work.
- Reduced CPU load and interrupts: the controller does buffering, error correction (ECC), format conversion and sector reading and interrupts only when finished.
- Simpler and smaller kernel / driver, with the device-specific details hidden behind a simple interface.
- Reliability and independence: a standard controller interface lets different devices work with the same OS.
Disadvantages
- Less flexible: firmware is fixed; policies (such as disk scheduling) cannot be changed or upgraded easily; a bug can be fixed only by new hardware or a firmware update.
- Higher hardware cost, and more complicated controllers.
- Poorer portability and sharing of information: the kernel has less knowledge of what the device is doing (cannot coordinate with global policies such as file system caching).
- Debugging is harder, and the kernel cannot protect the system against a faulty controller.
DMA
Direct Memory Access (DMA) lets an I/O device transfer a block of data directly to or from main memory without the CPU copying every byte. A special DMA controller (on the device controller or the motherboard) performs the transfer, and the CPU is interrupted only once, when the whole block is done.
The DMA controller has registers: a memory address register, a byte/word count register, and control register(s) (device, direction read/write, transfer unit, burst mode).
+-----+ +--------+ +-----------------+
| CPU | | Memory | | DMA controller |
+--+--+ +---+----+ | addr|count|ctrl |
| | +---+---------+---+
=====+==========+============|=========|==== bus
+-----+-----+
| Disk ctrl |
+-----------+
Steps (read from disk):
- The CPU programs the DMA controller (address, count, direction) and tells the disk controller to read a block.
- The disk controller reads the block into its internal buffer and checks the checksum.
- The DMA controller requests the bus and transfers data to the memory address, incrementing the address and decrementing the count (cycle stealing - it takes bus cycles from the CPU).
- When the count reaches zero the DMA controller sends an interrupt to the CPU.
- The CPU runs the interrupt handler; data is already in memory.
Modes: cycle-stealing (one word at a time), burst (a block at once). Advantages: the CPU is free for other work, faster transfers and fewer interrupts (one per block instead of one per byte). Disadvantage: extra hardware, and bus contention.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Programmed I/O, DMA, device-independent software · Operating System, chapter 6
- Monolithic vs micro-kernel structure · Operating System, chapter 1
- Process vs thread; user and kernel threads · Operating System, chapter 2
- DMA controller block diagram and transfer · Computer Organization and Architecture, chapter 7 · asked 6×
- Short note: DMA controller · Microprocessor, chapter 4 · asked 4×
- DMA controller and flow of actions · Embedded System, chapter 5 · asked 3×
- Microkernel vs monolithic kernel · Distributed System, chapter 3