Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between interrupt and event

Tags:

What is the difference between interrupt and an event?

like image 901
srikanth rongali Avatar asked Nov 23 '09 06:11

srikanth rongali


People also ask

What is difference between interrupt and event?

The terms interrupt and event often depend on context. operating-system kernel are the tags. So, I think that explains the context. interrupts are hardware events, events are software interrupts.

What is difference between interrupt and exception?

An exception is an unexpected event from within the processor. Interrupt is an unexpected event from outside the process. Whenever an exception or interrupt occurs, the hardware starts executing the code that performs an action in response to the exception.

What is meant by interrupt event?

Interruption Event means any cause which is beyond the reasonable control of a Party and directly prevents that Party from performing this Agreement, including: war, civil commotion, armed conflict, riot, act of terrorism, criminal damage, fire, flood, intervention by a Regulator, or compliance with any Applicable Law.

What is difference between interrupt and polling?

The main difference between interrupt and polling is that, in the case of an interrupt, the system informs the CPU that it needs attention, while talking about polling, the CPU constantly inspects the status of the system to find whether it needs attention.


1 Answers

These two concepts both offer ways for the "system/program" to deal with various "conditions" which take place during the normal unrolling of some program, and which may require the "system/program" to do something else, before returning (or not...) to the original task. However, aside from this functional similarity, they are very distinct concepts used in distinct contexts, at distinct levels.

Interrupts provide a low-level device to interrupting the normal unrolling of whatever piece of program the CPU is working on a a given time, and to have the CPU start processing instructions at another address. Interrupts are useful to handle various situations which require the CPU's immediate processing (for example to deal with keystrokes, or the arrival of new data in a serial communication channel).

Many interruptions are produced by hardware (by some electronic device changing the polarity on one of the pins of the CPU), but there are also software interrupts which are cause by the program itself invoking a particular instruction. (or also by the CPU detecting something is astray with regard to itself or the program running).

A very famous interrupt is INT 0x21 which program invoke[d] to call services from MS-DOS.

Interrupts are typically dispatched by way of vector tables, whereby the CPU has a particular location in memory containing an array of addresses [where particular interrupt handlers reside]. By modifying the content of the interrupt table [if it is so allowed...], a program can redefine which particular handler will be called for a given interrupt number.

Events, on the other hand, are system/language-level "messages" which can be used to signify various hardware or software situations (I'd use the word event), such as Mouse clicks, keyboard entries, but also application-level situations such as "New record inserted in database" or highly digested requests and messages, used in modular programs for communication/requests between various parts of the program.

Unlike interrupts with their [relatively simple] behavior which is fully defined by the CPU, there exist various event systems systems, at the level of the operating system as well as various frameworks (ex: MS Windows, JavaScript, .NET, GUI frameworks like QT etc..). All events systems, while different in their implementations, typically share common properties such as

  • the concept of a handler, which is a particular function/method of the program which is designated to handle particular types of event from particular event sources.
  • the concept of an event, which is a [typically small] structure containing information about the event: its type, its source, custom parameters (which semantics depend on the event type)
  • a queue where events are inserted by sources and polled by consumers/handlers (or more precisely by dispatchers, depending on system...)
like image 151
mjv Avatar answered Sep 28 '22 00:09

mjv