Enable and Disable Interrupts Two more ways to enable and disable interrupts are: Setting Processor Status register bit to 1/0 Processor automatically disables or enables interrupts by updating the interrupt enable/disable bit in PSR. Setting to 1 enables interrupt Setting to 0 disables interrupt Using Interrupt request line Processor has interrupt request line for which interrupt handling circuit responds only to the leading the edge of the signal called edge triggered. In this case, processor will receive only one request and there is no danger of multiple interruptions and no need of disable interrupt request Handling Multiple devices 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. This gives rise to a number of questions: 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? Handling Multiple Devices Consider a simple arrangement where all devices send their interrupt-requests over a single control line in the bus. When the processor receives an interrupt request over this control line, how does it know which device is requesting an interrupt? This information is available in the status register of the device requesting an interrupt: The status register of each device has an IRQ bit which it sets to 1 when it requests an interrupt. Interrupt service routine can poll the I/O devices connected to the bus. The first device with IRQ equal to 1 is the one that is serviced. Polling mechanism is easy, but time consuming to query the status bits of all the I/O devices connected to the bus. Vectored Interrupts: Handling Multiple Devices Another method: 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) to 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. Programmer gains some flexibility by storing a branch instruction to the appropriate ISR. Usually the location pointed to by the interrupting device is used to store the starting address of the interrupt-service routine. Processor reads this address called Interrupt Vector. Nested Interrupts Previously, before the processor started executing the interrupt service routine for a device, it disabled the interrupts from the device. In general, same arrangement is used when multiple devices can send interrupt requests to the processor. During the execution of an interrupt service routine of device, the processor does not accept interrupt requests from any other device. Since the interrupt service routines are usually short, the delay that this causes is generally acceptable. However, for certain devices this delay may not be acceptable. Which devices can be allowed to interrupt a processor when it is executing an interrupt service routine of another device? Nested Interrupts I/O devices are organized in a priority structure: An interrupt request from a high-priority device is accepted while the processor is executing the interrupt service routine of a low priority device. A priority level is assigned to a processor that can be changed under program control. Priority level of a processor is the priority of the program that is currently being executed. When the processor starts executing the interrupt service routine of a device, its priority is raised to that of the device. If the device sending an interrupt request has a higher priority than the processor, the processor accepts the interrupt request. Nested Interrupts Processor’s priority is encoded in a few bits of the processor status register. Priority can be changed by instructions that write into the processor status register. Usually, these are privileged instructions, or instructions that can be executed only in the supervisor mode. Privileged instructions cannot be executed in the user mode. Prevents a user program from accidentally or intentionally changing the priority of the processor. If there is an attempt to execute a privileged instruction in the user mode, it causes a special type of interrupt called as privilege exception. Implementation of interrupt priority using individual interrupt request and acknowledge lines Priority arbitration Device 1 Device 2 Device p INTA1 INT R 1 I NT R p INTA p •Each device has a separate interrupt-request and interrupt-acknowledge line. •Each interrupt-request line is assigned a different priority level. •Interrupt requests received over these lines are sent to a priority arbitration circuit in the processor. •If the interrupt request has a higher priority level than the priority of the processor, then the request is accepted. Processor Handling Simultaneous Requests Which interrupt request does the processor accept if it receives interrupt requests from two or more devices simultaneously?. If the I/O devices are organized in a priority structure, the processor accepts the interrupt request from a device with higher priority. Each device has its own interrupt request and interrupt acknowledge line. A different priority level is assigned to the interrupt request line of each device. However, if the devices share an interrupt request line, then how does the processor decide which interrupt request to accept? Handling Simultaneous Requests Device 2 I NT R INTA Device n Device 1 Polling scheme: •If the processor uses a polling mechanism to poll the status registers of I/O devices to determine which device is requesting an interrupt. •In this case the priority is determined by the order in which the devices are polled. •The first device with status bit set to 1 is the device whose interrupt request is accepted. Daisy chain scheme: •Devices are connected to form a daisy chain. •Devices share the interrupt-request line, and interrupt-acknowledge line is connected to form a daisy chain. •When devices raise an interrupt request, the interrupt-request line is activated. •The processor in response activates interrupt-acknowledge. •Received by device 1, if device 1 does not need service, it passes the signal to device 2. •Device that is electrically closest to the processor has the highest priority. Processor Handling Simultaneous Requests •When I/O devices were organized into a priority structure, each device had its own interrupt-request and interrupt-acknowledge line. •When I/O devices were organized in a daisy chain fashion, the devices shared an interrupt-request line, and the interrupt-acknowledge propagated through the devices. •A combination of priority structure and daisy chain scheme can also used. Device Device circuit Priority arbitration Device Device I NT R 1 INT R p INTA1 INTA p •Devices are organized into groups. •Each group is assigned a different priority level. •All the devices within a single group share an interrupt-request line, and are connected to form a daisy chain. Processor Controlling I/O Devices(4.2.4) Only those devices that are being used in a program should be allowed to generate interrupt requests. To control which devices are allowed to generate interrupt requests, the interface circuit of each I/O device has an interrupt-enable bit. If the interrupt-enable bit in the device interface is set to 1, then the device is allowed to generate an interrupt-request. Interrupt-enable bit in the device’s interface circuit determines whether the device is allowed to generate an interrupt request. Interrupt-enable bit in the processor status register or the priority structure of the interrupts determines whether a given interrupt will be accepted.
Explain these topics in simpler terms
Here's a simpler explanation of the mentioned topics:
Enable and Disables: Enabling and disabling interrupts can be done in a couple of ways. For instance, one method involves updating the Processor Status Register (PSR) bit: setting it to 1 enables interrupts, while setting it to 0 disables interrupts. Another way is using the interrupt request line, which responds to the leading edge of the signal for edge-triggered interrupts.
Handling Multiple Devices: When multiple I/O devices are connected to a processor, each device may be capable of generating interrupt requests. The processor needs to know which device has generated an interrupt and which interrupt service routine needs to be executed. To handle this, different methods can be used, such as polling the I/O devices or using special codes from the devices to identify themselves to the processor.
Nested Interrupts: In certain cases, a processor needs to decide if it should allow an interrupt from a device while it's already dealing with an interrupt from another device. Nested interrupts handle this by organizing I/O devices based on priority. The interrupt service routine of a device can be interrupted by a higher-priority device. This is done by changing the priority level of the processor to that of the interrupting device.
Handling Simultaneous Requests: If the processor receives interrupt requests from multiple devices simultaneously, it needs a method to determine which request to accept. This can be done using a polling or daisy chain scheme. In a polling scheme, the priority is determined by the order in which the devices are polled, while in a daisy chain scheme, the interrupt-acknowledge line is connected through the devices and the device closest to the processor has the highest priority.
Controlling I/O Devices: To control which devices are allowed to generate interrupt requests, each I/O device has an interrupt-enable bit in its interface circuit. If this bit is set to 1, the device is allowed to generate an interrupt-request. Additionally, the interrupt-enable bit in the processor status register or the priority structure of the interrupts determines whether a given interrupt will be accepted.
cwiki.apache.org
geeksforgeeks.org
oreilly.com