Interrupts and interrupt system

Break: I did not, want to improve your computer's performance, dreaming!

Imagine a scene:
small macros are eating, suddenly received a phone company is required immediately rushed to the meeting of the company. And the little Acer made the following few things:

  1. Fangxiawankuai
  2. Take the car keys
  3. Go to the garage to get the car
  4. The company arrived

As is often the scene can be seen in their lives, in this article, the term can have a good interpretation of this scene - interrupted.

Interrupt

Require a small company called Wang immediately go to company meetings, so little macro must lay down did not finish the meal, instead rush to company meetings, and other finish will continue to eat at home again. These actions to show the concept of interruption. And that is a small macro interrupt device.

What is the break ?
Some kind of emergency in the program is running, you must stop the program currently running, turn to handle this event, and then restore the original run of the program, this process is called interrupted.
What is the interruption means ?
Interrupt hardware part of the system, whose function is to detect and respond to interrupts, in particular:

  1. Identify the interrupt source
  2. Save site
  3. Leads to interrupt handler

Interrupt Source

The company immediately to telephone for small macro meeting of the company, which is caused by small macro may not go Fangxiawankuai meeting of the company's incident. In computer terms, also known as an interrupt source.

Cause of the interruption event called the interrupt source .

Interrupt word

When the macro to a small company into the conference room to start a meeting at this time:

  1. Take out your notebooks
  2. Start recording the meeting content
    above is a small macro handle interrupt events, we said, the notebook is interrupted recorder, the content recorded on the laptop was interrupted word.

After the discovery and interrupting means interrupts, the interrupt handler to the response.
Hardware for each interrupt source set up a register, that is interrupt register , and interrupt register kept some information related to the interrupt events, this information is called the interrupt word .

Interrupt type

Small macro recorder for a while, find yourself some questions about the contents, then mark down, waiting for a meeting of the question period throw this question.
Small macro is now doing its own conscious arrangements, and make a voluntary, we call this voluntary interruption. Since there are voluntary, there is a relative of forced interruption, the company was called to a meeting, which belongs to the forced interruption

  1. Forced break :
    this type of interrupt event is running the program lock is not desired, whether such interruption occurred, when it occurred, unpredictable.
    • Clock interrupt
    • O interrupt
    • Console break
    • Hardware fault interrupt
    • Program error interrupt
  2. Voluntary interrupts :
    These interrupts events are running programs conscious arrangements, such disruption has occurred inevitability, the timing of occurrence, location determination.

Interrupt vector

A macro is a small conference room at the technical department open technology seminar, which is called the interrupt vector.
Technology conference room corresponding to the interrupt routine entry address (PC) , corresponding technical seminar is a runtime environment (PSW) , collectively known as PC and PSW interrupt vector.

NOTE:
treatment of similar events is the same, so not every interrupt source has an interrupt handler, but every time there is a class break interrupt handler.

Interrupt nesting

Small macro throws doubt on the question period, which occurs when processing the first interrupt events, this is a nesting. We know that leadership is not allowed to speak at meetings to be interrupted, unless it is interrupted by a higher level of leadership (0 ..... 0), this is the priority problem interrupts and interrupt masking.

Interrupt nesting is mainly nested , although nesting can go on endlessly, but, due to the presence of interrupt priority so that the current interrupt can only be interrupted by higher priority events, so it is impossible to interrupt nesting unlimited .
Would like to appear low-priority interrupt event is not feasible, only we need to adjust priorities, such as the question period at the time of the meeting to raise the priority of the general staff.
Note:
When an interrupt occurs, you need to save (using the save stack, the stack area location is determined by the hardware) interrupted the program on-site information to ensure that after processing the interrupt event can recover the site.

Interrupt priority

Hardware requirements, can not be changed, but the program may be appropriate to make adjustments.

As a priority higher than the leadership of the general staff (you say who provided it? ¯ ▽ ¯)

Interrupt Mask

Interrupt mask instructions may temporarily disable interrupts, an interrupt request source to the processor.

Even if it is leadership, at conferences also can not interrupt the meeting were ︿ (¯)¯) ︿.

Interrupt handler

Small macro at the meeting did what action, remember? Those action on the formation of a handler.

Process interrupt handler processing interrupts may be used in general-purpose registers, it is necessary to preserve the scene for further information.
What information is saved scene it? What needs attention when you save it?
When the interrupt processing is complete return to the user program, you need an instruction by the PC and PSW system stack pop, why?

Save site information : PC, PSW and general register
must be noted when saving : on-site information stored in the system stack, does not respond in the process of saving and restoring the site of the new interrupt (interrupt mask).
An instruction to restore the PC and PSW : interrupt vector in the PSW and the contents of the instruction counter PC must be restored at the same time by a single instruction, so as to ensure the system state by the state to mesh tube state at the same time, control is passed to increase process breakpoint continues to perform. (2) to restore the PC and then restore PSW, PC changed; if you do not recover at the same time, only (1) first and then restore PC restore PSW, after the recovery has been transferred to head state PSW, PC operating system recovery mission can not be completed In addition to the operating system area (because the state system is still PSW), PSW can not be recovered.

Guess you like

Origin www.cnblogs.com/keepsmart/p/11371430.html