Using Interrupts

An interrupt is a procedure that is associated with an event. Specifying an interrupt allows a process to continue executing other statements at the same time that it waits on an event. When the event is caused, control passes directly to the interrupt procedure. When the interrupt procedure finishes, the process resumes execution where it left off.

An interrupt cannot be invoked using any of the standard procedure invocation statements. An interrupt is entered only when the associated event is caused. Causing an event invokes the interrupt even if the event is already in a HAPPENED state. Therefore, there is no effective difference between using a cause statement or a cause and reset statement to invoke the interrupt.

You can use attach and detach statements to specify with which event an interrupt is associated. Execution of the interrupt can be selectively allowed or suppressed through the use of enable and disable statements. The statements that attach or detach and enable or disable an interrupt can occur in any order, and do not affect each other. For example, detaching an interrupt does not also cause it to be disabled. The initial state of an interrupt is detached and enabled.

An interrupt might not always execute immediately when its event is caused. Any of the following three circumstances can delay execution of an interrupt:

  • The interrupt is disabled.

  • The process is waiting on an event. Any interrupts that are caused are queued and executed when the process resumes.

  • The processor is engaged in executing a higher-priority process.