











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












Topics covered: Input/Output Organization
(^) We have seen instructions to: (^) Transfer information between the processor and the memory. (^) Perform arithmetic and logic operations (^) Program sequencing and flow control. (^) Input/Output operations which transfer data from the processor or memory to and from the real world are essential. (^) In general, the rate of transfer from any input device to the processor, or from the processor to any output device is likely to the slower than the speed of a processor. (^) The difference in speed makes it necessary to create mechanisms to synchronize the data transfer between them.
DATAIN DATAOUT SIN SOUT Keyboard Display Bus Processor Input:
DATAIN DATAOUT SIN SOUT Keyboard Display Bus Processor Output:
Bus I/O device 1 I/O device n Processor Memory
(^) I/O devices and the memory may share the same address space: (^) Memory-mapped I/O. (^) Any machine instruction that can access memory can be used to transfer data to or from an I/O device. (^) Simpler software. (^) I/O devices and the memory may have different address spaces: (^) Special instructions to transfer data to and from I/O devices. (^) I/O devices may have to deal with fewer address lines. (^) I/O address lines need not be physically separate from memory address lines. (^) In fact, address lines may be shared between I/O devices and memory, with a control signal to indicate whether it is a memory address or an I/O address.
(^) Recall that the rate of transfer to and from I/O devices is slower than the speed of the processor. This creates the need for mechanisms to synchronize data transfers between them. (^) Program-controlled I/O: (^) Processor repeatedly monitors a status flag to achieve the necessary synchronization. (^) Processor polls the I/O device. (^) Two other mechanisms used for synchronizing data transfers between the processor and memory: (^) Interrupts. (^) Direct Memory Access.
(^) In program-controlled I/O, when the processor continuously monitors the status of the device, it does not perform any useful tasks. (^) An alternate approach would be for the I/O device to alert the processor when it becomes ready. (^) Do so by sending a hardware signal called an interrupt to the processor. (^) At least one of the bus control lines, called an interrupt- request line is dedicated for this purpose. (^) Processor can perform other useful tasks while it is waiting for the device to be ready.
(^) Treatment of an interrupt-service routine is very similar to that of a subroutine. (^) However there are significant differences: (^) A subroutine performs a task that is required by the calling program. (^) Interrupt-service routine may not have anything in common with the program it interrupts. (^) Interrupt-service routine and the program that it interrupts may belong to different users. (^) As a result, before branching to the interrupt-service routine, not only the PC, but other information such as condition code flags, and processor registers used by both the interrupted program and the interrupt service routine must be stored. (^) This will enable the interrupted program to resume execution upon return from interrupt service routine.
(^) Saving and restoring information can be done automatically by the processor or explicitly by program instructions. (^) Saving and restoring registers involves memory transfers: (^) Increases the total execution time. (^) Increases the delay between the time an interrupt request is received, and the start of execution of the interrupt-service routine. This delay is called interrupt latency. (^) In order to reduce the interrupt latency, most processors save only the minimal amount of information: (^) This minimal amount of information includes Program Counter and processor status registers. (^) Any additional information that must be saved, must be saved explicitly by the program instructions at the beginning of the interrupt service routine.
(^) Interrupt-requests interrupt the execution of a program, and may alter the intended sequence of events: (^) Sometimes such alterations may be undesirable, and must not be allowed. (^) For example, the processor may not want to be interrupted by the same device while executing its interrupt-service routine. (^) Processors generally provide the ability to enable and disable such interruptions as desired. (^) One simple way is to provide machine instructions such as Interrupt-enable and Interrupt-disable for this purpose. (^) To avoid interruption by the same device during the execution of an interrupt service routine: (^) First instruction of an interrupt service routine can be Interrupt- disable. (^) Last instruction of an interrupt service routine can be Interrupt- enable.
(^) Multiple I/O devices may be connected to the processor and the memory via a bus. Some or all of these devices may be capable of generating interrupt requests. (^) Each device operates independently, and hence no definite order can be imposed on how the devices generate interrupt requests? (^) How does the processor know which device has generated an interrupt? (^) How does the processor know which interrupt service routine needs to be executed? (^) When the processor is executing an interrupt service routine for one device, can other device interrupt the processor? (^) If two interrupt-requests are received simultaneously, then how to break the tie?
(^) The device requesting an interrupt may identify itself directly to the processor. (^) Device can do so by sending a special code (4 to 8 bits) the processor over the bus. (^) Code supplied by the device may represent a part of the starting address of the interrupt-service routine. (^) The remainder of the starting address is obtained by the processor based on other information such as the range of memory addresses where interrupt service routines are located. (^) Usually the location pointed to by the interrupting device is used to store the starting address of the interrupt-service routine.