Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






Input-output and interruptions.

Interrupt – signal informing the processor of the approach of any event. Thus execution of the current sequence of commands stops and control is transferred to the processor of interruption which reacts to an event and services, and then it returns the control in the interrupted code.

Interrupt handler (or procedure of service of interruptions) – the special procedure caused on interruption for execution of its processing. Interrupt handlers can execute a set of functions which depend on the reason which caused interruption.

The interrupt handler is a low level equivalent of an event handler. These processors are called on the hardware interrupt or the appropriate instruction in the program, and they are respectively intended for interaction with devices or for implementation of a call of functions of an operating system.

On the modern PCs processors the main hardware and software interrupts are in the memory of BIOS. The modern operating system during the loading, replaces these processors with its own processors.

1. Hardware, synchronous or interrupt traps – events in the processor as the result of violation of any conditions at execution of a machine code: division into a zero or overflow, appeal to inadmissible addresses or inadmissible code of operation.

2. Input-output interrupt, asynchronous or external – events which proceed from external sources (for example, peripheral devices) and they can occur during any arbitrary moment: a signal from the timer, the network interface card or the disk storage module, clicking of keys of the keypad, movement of a mouse. The origin fact in system of such interruption as interrupt request is fixed (English Interrupt request, IRQ).

3. Software interrupts, exceptions (a special case of interrupt trap) – the synchronous interruption which the program by means of the special instruction can realize. Software interrupts as a rule are used for the appeal to functions of the firm ware, drivers and an operating system.

4. Timer interrupt (the special case of interrupt trap) is generated by the timer of the processor of times in 55 msec (about 18,2 times a second). This interruption allows an operating system to execute some functions periodically, through the given periods.

Interrupt vector – number assigned to the device which identifies the appropriate interrupt handler.

Vectors of interruptions integrate in the interrupt vector table containing addresses of interrupt handlers. Location of the table depends on type and processor operation mode.

From the point of view of the program of the user, interruption is different from violation in normal sequence of execution. After completion of processing of interruption operation restarts. Thus, the program of the user doesn’t include any special code to adapt to interruptions. For suspension of the program of the user and restoration of its operation from that place in which it was interrupted, the processor and an operating system respond.

1) Interruptions and external devices



Interruptions are generally intended for overall performance increase. For example, the majority of input/output devices work much more slowly than the processor. Let's assume that the processor transfers data to the printer. After each operation the processor is stimulated to do a pause and to wait, while the printer won't accept data. Duration of this pause can be in hundreds and even thousands time more than the command cycle duration in which storage accesses participate. It is clear, that similar use of the processor is ineffective.

The program of input-output consists of three parts.

1.Sequence of commands which serve for preparation for actually input-output operations. In this sequence copying of deduced data into the special buffer and preparation of a set of the parameters necessary for control of the device can enter.

2. Actually input-output commands. If the program doesn't use interruptions, it should wait, while the input/output device won't execute required operations (or periodically to check its status by inquiry). Thus the program has to wait, permanently checking, whether input-output operation came to the end.

3. Sequence of commands which serve for operation completion. This sequence can comprise installation of the flags testifying if the operation is successful or unsuccessful.

Because of that to execute the input-output operation the long period can be demanded, the program decelerates operation, expecting operation completion. Thus, where WRITE call meets, the productivity of the program essentially decreases.

Thanks to interruptions in runtime of input-output operations the processor can be occupied with processing of other commands. Let's consider other course of process. As well as in the previous case (without use of interruptions), having called the WRITE procedure, the program addresses to system. The program of input-output which consists of a preparatory code and actually input-output commands is activated. After execution of these commands control is transferred to the program of the user. Meanwhile the external device is occupied with reception of data from memory of the computer and their processing (for example if this device is the printer, processing is meant as printout). Input-output occurs at the same time to execution of commands of the program of the user.

While the external device is released and ready for further operation, i.e. it is ready to accept a new portion of data from the processor, the peripheral control unit of this device sends to the processor a signal of request of interruption. In reply the processor pauses execution of the current program, switching to operation with the program servicing this input/output device (this program is called an interrupt handler). Having serviced the external device, the processor again restarts the interrupted operation.

2) Interruptions and cycle of execution of the program

To coordinate interruption with the program, in a cycle of a command the interruption cycle is added. In an interruption cycle the processor checks the existence of signals of the interruptions testifying the interruptions. In case of interruption arrival the processor pauses operation with the current program and executes an interrupt handler. Interrupt handlers normally are a part of an operating system. As a rule, these programs define the nature of interruption and execute necessary actions. For example, in a used example the processor defines what of peripheral control units generate interruption; besides, it can transfer control to the program which deduces the data on the input/output device. When the interrupt handler finishes the operation, the processor restarts execution of the program of the user from that place where it was interrupted.

It is clear, that this process includes some unproductive expenses. For determination of the nature of interruption and making decision on the subsequent actions the interrupt handler must execute additional commands. Nevertheless, in view of that waiting of completion of input-output operations would need rather big interval of time, by means of interruptions the processor can be used much more effectively.

3) Interrupt handling

Interruption causes a row of events which occur both in hardware and in the software. Because of that the interruption isn't the subprogram caused from the program, it is important to save all information of a status of the preemptive program. However interruption can occur at any time and in any place of the program of the user. This event is unpredictable.

Multiple interruptions

We still considered a case of origin of one interruption. Let's imagine a situation when there can be some interruptions. For example, the program obtains data on a line of communication and at once prints the result. The printer will generate interruption in case of each completion of operation of the printing, and the controller of a line of communication – in case of each arrival of a new portion of data. This portion can consist of one character or from the whole unit, depending on a service established order. The situation when communication interruption will occur during processing of interruption of the printer is in any case possible.

In such situation two approaches are possible. The first is to forbid new interruptions until the previous is processed.

Interrupt disabling means that the processor can and must ignore any new signal of interruption. If at this time there is an interruption, it normally remains in idle state, and it will be reached by queue when the processor can process again interruptions. Thus, if during an operating time of the program of the user there is an interruption, the ban is right there imposed on other interruptions. After completion of a program runtime of processing of interruption the prohibition acts in film, and before return to execution of the interrupted program the processor checks existence of other interruptions. It is a successful and naive approach in case of which interruptions are processed in strictly serial order.

1) Masking of interruptions

· Depending on prohibition possibility external interruptions share on:

· masked interrupts – interruptions which can be forbidden installation of the appropriate bits in the register of masking of interruptions (in x86-processors – reset of a flag of IF in the register of flags);

Not masked interrupts (NMI) – are processed always, irrespective of prohibitions of other interruptions. For example, such interruption can be called failure in a memory chip.

Interrupt handlers are normally written so that time of their processing was smaller, during their operation other interruptions can’t be processed and if there are many interruptions (especially from one source), they can be lost.

2) Prioritization of interruptions

Before the completion of processing of interruption the prohibition on processing of this type of interruption is established in order the processor didn't enter into an operation cycle of one interruption. Prioritization means that all sources of interruptions share on classes and the level of a priority of interrupt request on each class is assigned. Priorities can be serviced as the relative and absolute.

The relative service of interruptions means that if during processing of interruption more priority interruption arrives, this interruption will be processed only after completion of the current processing procedure of interruption.

Absolute service of interruptions means that if during processing of interruption more priority interruption arrives, the current processing procedure of interruption is forced out and the processor starts to execute processing of again arrived more priority interruption. After completion of this procedure the processor returns to execution of the forced-out processing procedure of interruption.


Date: 2015-12-24; view: 330


<== previous page | next page ==>
Program control principle. The program consists of command set which is fulfilled by the processor automatically one after another in certain sequence. | Devices of memory of the computer.
doclecture.net - lectures - 2014-2017 year. Copyright infringement or personal data (0.024 sec.)