Several devices may need attention together, as when a keyboard key is pressed while a disk finishes reading. The system must decide which is served first. Direct memory access removes the load of moving large blocks of data from the processor.
Priority Interrupt
A priority interrupt system decides which of several interrupts to serve first, and decides whether a new interrupt may stop the one being served. There are two ways. In polling the software checks the devices in order of priority, which is simple but slow. In hardware priority schemes the circuits decide at once.
Definition: Priority interrupt. A scheme that determines which interrupt source is served first when two or more devices request service at the same time.
Daisy Chain Priority
In the daisy chain the devices are connected in series. An interrupt acknowledge signal enters the first device, which has the highest priority. If that device did not request an interrupt, it passes the signal to the next one through its priority out line (PO). A device that did request keeps the signal and places its vector address on the bus. Devices nearer the processor therefore have a higher priority.
Parallel Priority and Direct Memory Access
In parallel priority, a mask register can disable chosen interrupts, and a priority encoder gives the code of the highest-priority request. Direct memory access uses a DMA controller with an address register, a word count register and a control register. The controller sends a bus request (BR) to the processor. The processor finishes the present cycle and replies with a bus grant (BG), and the DMA controller then moves the data directly between the device and memory. In burst mode a whole block is moved, and in cycle stealing one word is moved at a time between processor cycles.
Table 4.8: Interrupt priority methods
| Method | Decision made by | Speed |
|---|---|---|
| Polling | Software | Slow |
| Daisy chain | Serial hardware | Medium |
| Parallel priority | Mask register and encoder | Fast |
Example 4.7: DMA transfer of a block
Problem: A disk sends a block of 512 words to memory by DMA, starting at address 2000. State the contents of the DMA registers at the start and the end.
Solution:
- At the start the address register holds 2000 and the word count register holds 512.
- After each word the address is increased by 1 and the count is decreased by 1.
- After 512 words the address register holds 2512 and the count is 0.
Result: When the word count reaches zero, the controller stops and interrupts the processor to signal completion.
addr, count = 2000, 512
while count:
addr += 1
count -= 1
print(addr, count)
Output
2512 0
Common mistakes
- Believing that the device nearest the end of the daisy chain has the highest priority.
- Thinking that the processor moves every word in DMA.
- Forgetting that the DMA controller needs the bus grant before it transfers data.
Key takeaways
- Priority interrupts decide which device is served first.
- In the daisy chain the nearest device to the processor has the highest priority.
- A DMA controller has an address register, a word count register and a control register.
- DMA uses BR and BG signals to take control of the bus.
Practice questions
- What is the function of the mask register?
- Which device has the highest priority in a daisy chain?
- What is cycle stealing?
Answers to the practice questions
- It disables selected interrupt requests.
- The device nearest to the processor.
- Transferring one word by DMA between processor cycles.
Sources
- Official BCA syllabus Computer Architecture, course code 25BCA401DS02, Unit IV
