Notas
Transfer of control via Interrupts
Conteúdo das notas (4)
Página 1
From the point of view of the user program, an interrupt is just that: an interruption
of the normal sequence of execution. When the interrupt processing is completed,
execution resumes. Thus, the user program does not have to contain any
special code to accommodate interrupts; the processor and the operating system are
responsible for suspending the user program and then resuming it at the same point.
Página 2
Instruction Cycle with Interrupts
In the interrupt cycle, the processor checks to see if
any interrupts have occurred, indicated by the presence of an interrupt signal. If no
interrupts are pending, the processor proceeds to the fetch cycle and fetches the
next instruction of the current program. If an interrupt is pending, the processor
does the following:
• It suspends execution of the current program being executed and saves its
context. This means saving the address of the next instruction to be executed
(current contents of the program counter) and any other data relevant to the
processor’s current activity.
• It sets the program counter to the starting address of an interrupt handler routine.
The processor now proceeds to the fetch cycle and fetches the first instruction
in the interrupt handler program, which will service the interrupt. The interrupt
handler program is generally part of the operating system. Typically, this program
determines the nature of the interrupt and performs whatever actions are needed.
In the example we have been using, the handler determines which I/O module
generated the interrupt and may branch to a program that will write more data out
to that I/O module. When the interrupt handler routine is completed, the processor
can resume execution of the user program at the point of interruption.
It is clear that there is some overhead involved in this process. Extra instructions
must be executed (in the interrupt handler) to determine the nature of the interrupt
and to decide on the appropriate action. Nevertheless, because of the relatively large
amount of time that would be wasted by simply waiting on an I/O operation, the
processor can be employed much more efficiently with the use of interrupts.
Página 3
Program Timing Short I/O Wait
In this figure, user program code segments are shaded green, and I/O program code segments are shaded gray.
a) shows the case in which interrupts are not used. The processor must
wait while an I/O operation is performed.
b) assumes that the time required for the I/O operation is
relatively short: less than the time to complete the execution of instructions between write
operations in the user program. In this case, the segment of code labeled code segment
2 is interrupted. A portion of the code (2a) executes (while the I/O operation is performed)
and then the interrupt occurs (upon the completion of the I/O operation). After
the interrupt is serviced, execution resumes with the remainder of code segment 2 (2b).
Página 4
Instruction Cycle (with Interrupts) - State Diagram
Informações
- Descrição
- Notas sobre Transfer of control via Interrupts, criado por Matthew Swart em 20-11-2018.
- Criado por
- Matthew Swart · nov 2018
- Atualizado
- 20 nov 2018
- Visualizações
- 10
- Avaliação
Mais sobre I/O Modules, Interfaces and Techniques