Wednesday, June 13, 2012

We interrupt this program . . .

". . . to bring you a special bulletin." -- Announcement preceding a "breaking news" story

COUNT ZERO INTERRUPT:  On receiving an interrupt, decrement the counter to zero. -- Count Zero by William Gibson [Actually, this is backward; it should be "when the counter is decremented to zero, an interrupt is generated."]

An interrupt is the method for notifying a computer program (usually the operating system) of an exceptional situation.  The currently running program is suspended and the process for handling the exception (the interrupt handler) is executed before resuming the previously running program.

The actions that occur during an interrupt are

  1)  an internal component or external device detects an exceptional situation.
  2)  the component or device sends an interrupt request to the Central Processing Unit.
  3)  the CPU saves the process's state and the address of the next instruction.
  4)  a new process state is set up and the address of the next instruction is set to the beginning of
       the interrupt handler.
  5)  the interrupt handler is executed, during which all lower-priority interrupts are deferred.


After the interrupt handler is finished it issues a "return from interrupt", after which

  1)  any pending lower-priority interrupts are handled.
  2)  the suspended program is resumed.

An interrupt can be generated for many situations such as
     floating point overflow
     divide by zero
     unrecognized instruction
     insufficient privilege to execute instruction
     access to memory location not permitted
     memory address translation exception
     data available for input
     device requires attention
     data transfer complete
     timer expired
     hardware error
     modification of a shared resource by multiple processes concurrently (on either a single
          processor or a multiprocessor system)
     interrupt on access to this address was requested (used for debugging)

The specific actions during an interrupt depends on the type of CPU, but most types store the next instruction address and state information on a stack, and get the starting address of the interrupt handler from a location in memory determined from the type of interrupt.  Interrupt handlers usually run in kernel (privileged) mode.

"We now return control of your television set to you . . ."  -- Closing title sequence from The Outer Limits


                   Dramatis Personae
Interrupt Hardware     as                Control Voice
Computer               as               Television Set
Interrupt Handler      as                News Bulletin
Return Stack           as     Broadcast Master Control
Peripheral Devices     as                 News Sources


Written by                         Computer Programmer
Directed by                        Instruction Pointer

0 Comments:

Post a Comment

Please enter your comment here. Comments wil be reviewed before being published.

Subscribe to Post Comments [Atom]

<< Home