The Great Symbian

Anything under the sun goes here!

  • Interrupts and Traps. A great deal of the kernel consists of code that is invoked as the result of a interrupt or a trap.
  • While the words "interrupt" and "trap" are often used interchangeably in the context of operating systems, there is a distinct difference between the two.
  • An interrupt is a CPU event that is triggered by some external device.
  • A trap is a CPU event that is triggered by a program. Traps are sometimes called software interrupts. They can be deliberately triggered by a special instruction, or they may be triggered by an illegal instruction or an attempt to access a restricted resource.
    When an interrupt is triggered by an external device the hardware will save the the status of the currently executing process, switch to kernel mode, and enter a routine in the kernel.
  • This routine is a first level interrupt handler. It can either service the interrupt itself or wake up a process that has been waiting for the interrupt to occur.
    When the handler finishes it usually causes the CPU to resume the processes that was interrupted. However, the operating system may schedule another process instead.
    When an executing process requests a service from the kernel using a trap the process status information saved, the CPU is placed in kernel mode, and control passes to code in the kernel.
  • This kernel code is called the system service dispatcher. It examines parameters set before the trap was triggered, often information in specific CPU registers, to determine what action is required. Control then passes to the code that performs the desired action.
    When the service is finished, control is returned to either the process that triggered the trap or some other process.
  • Traps can also be triggered by a fault. In this case the usual action is to terminate the offending process. It is possible on some systems for applications to register handlers that will be evoked when certain conditions occur -- such as a division by zero.

0 comments:

FEEDS

Add to Google Reader or Homepage