Principles of Computer Organization - interrupt program

The basic concept of interruption:

Program interruption refers to the process of realization of the program a computer to perform some unusual circumstances in urgent need of treatment or special request occurs, CPU to suspend the current procedures, and turn to these exceptions or special request for processing, and automatic CPU after processing return to the breakpoint current program, to continue implementation of the original program.

Interrupt system is a computer-implemented interrupt function of the software and hardware in general. In the CPU interrupt mechanism arranged on one side, arranged on the side of the device control interface interrupt, the software design of the corresponding interrupt service routine.

 

A complete interrupt process include:

Interrupt request: refers to the interrupt source (device that caused the event or interrupt) to the CPU
 request issued interrupt request.
Interrupt arbitration: When there are multiple interrupt request sources, need to decide the appropriate way to handle by which interrupt request;
interrupt response: refers to the process of the CPU suspends the current program go to the interrupt service routine;
interrupt processing: refers to the CPU to execute the interrupt service program;
interrupt return:    executing the interrupt service routine, the return to the interrupted program

 

Interruption action:

(1) CPU and I / O devices in parallel
(2) a hardware fault handling
(3) implement man-machine interface: a computer operation, if the user intervention to the machine, such as viewing intermediate results of calculations, to understand the state of the working machine, to the machine issued temporary orders. In a computer system without interruption in these functions it is almost impossible to achieve.
(4) to achieve multiprogramming and timesharing
(5) to achieve real-time processing
(6) the operating system and applications to achieve the contacts
(7) multiprocessor system links between the processors

Interrupt generation and corresponding concept

(1) interrupt sources:

Event caused the interrupt, the interrupt request is issued sources.
  ■ external interrupt : I / O interrupt from the host equipment external device. (Commonly referred to as external interrupt is interrupt)
  ■ internal interrupts : interrupt handler hardware failure or program error caused.
  ■ Soft interrupts : Soft produced by "the Trap" interrupt instruction, which is pre-arranged in a program     
interrupt triggers: each interface circuit has an interrupt source in "interrupt trigger" for saving the interrupt sources CPU interrupt request signal. A plurality of flip-flops Interrupt Interrupt Register.

 Interrupt the abnormal internal classification of the main CPU shown in the figure, the exception, has returned to the ranks of the fall in the disruption, the distinction is not caused by hardware or software caused a.

 

(2) interrupts and interrupt priority rating 

In designing the system interrupt, interrupt by interrupt sources make all processed and the nature and priorities given priority queue.

(3) disable interrupts and interrupt masking

a, disable interrupts:
the interrupt source, due to the presence of certain conditions, CPU current can not suspend execution of the program, called disable interrupts .
Generally provided within the CPU of a "interrupt enable" flip-flop is only "1", in response to the interrupt handler is allowed, on the contrary, not all of the interrupt source interrupt request.
"Interrupt enable" triggers can be set and reset by the "break open" and "off interrupt" instruction.
B, interrupt mask
generated when an interrupt request, program mode to selectively block some interruption, while still allowing the remainder of the interrupt response obtained.
This is accomplished by each interrupt source to an interrupt mask is provided a trigger device to mask the interrupt request. Interrupt mask trigger each device constituting the interrupt mask register.
Of course, some interrupt source interrupt request is non-maskable. So interrupt divided into maskable interrupts and non-maskable interrupts.

Interrupt processing

 

Interrupt processing:

 

(1)关中断
 进入不可再次响应中断的状态,由硬件自动实现。在保存现场过程中,即使有更高级的中断源申请中断,CPU也不应该响应。否则,如果现场保存不完整,在中断服务程序结束之后,也就不能正确地恢复现场并继续执行现行程序。
(2)保存断点和现场
  现场信息一般指的是程序状态字,中断屏蔽寄存器和CPU中某些寄存器的内容。
(3)判别中断源,转向中断服务程序。
 在多个中断源同时请求中断的情况下。本次实际响应的只能是优先权最高的那个中断源、所以,需进一步判别中断源,并转入相应的中断服务程序入口。
(4)开中断。接下去就要执行中断服务程序,开中断将允许更高级中断请求得到响应。实现中断嵌套。
(5)执行中断服务程序。
(6)退出中断。在退出时,又应进入不可中断状态,即关中断,恢复现场、恢复断点,然后开中断,返回原程序执行
   进入中断时执行的关中断、保存断点等操作一般是由硬件实现的,它类似于一条指令,但它与一般的指令不同,不能被编写在程序中。因此,常常称为‘中断隐指令’。

判别中断源

判别中断源可以用软件和硬件两种方法来判优。
 (1)查询法(软件法)
由测试程序按一定优先排队次序检查各个设备的“中断触发器”。当遇到第一个‘1’标志时,即找到了优先进行处理的中断源,通常取出其设备码,根据设备码转入相应的中断服务程序。
(2)串行排队链法(硬件判优)
由硬件确定中断源。
问题:找到优先级最高的中断请求后,如何转入其中断服务程序?
一般采用中断向量法:
向量中断方式是为每一个中断源设置一个中断向量(就是中断服务程序的入口地址),所有的中断向量存放在主存的某个固定位置(中断向量表)。CPU响应某个中断源的中断请求时,根据设备提供的中断类型码,访问中断向量表,就可以找到该中断源的中断服务程序的入口地址。

 

Guess you like

Origin www.cnblogs.com/wkfvawl/p/10957080.html