Trap (computing)

From HandWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

In computing and operating systems, a trap, also known as an exception or a fault, is typically[NB 1][1] a type of synchronous interrupt caused by an exceptional condition (e.g., breakpoint, division by zero, invalid memory access). A trap usually results in a switch to kernel mode, wherein the operating system performs some action before returning control to the originating process. A trap in a kernel process is more serious than a trap in a user process, and in some systems is fatal. In some usages, the term trap refers specifically to an interrupt intended to initiate a context switch to a monitor program or debugger.[2]

Deriving from this original usage, trap is sometimes used for the mechanism of intercepting normal control flow in some domains.[3]

In SNMP, a trap is a type of PDU used to report an alert or other asynchronous event about a managed subsystem.

See also

Notes

  1. There is a wide variation in the nomenclature. On some computers the term trap refers to any interrupt, on some machines to any synchronous interrupt, on some machines to any interrupt not associated with input/output, on some machines only to interrupts caused by instructions with trap in their names, etc.

References

  1. Hyde, Randall (1996). "CHAPTER SEVENTEEN: INTERRUPTS TRAPS AND EXCEPTIONS (Part 1)". The Art Of Assembly Language Programming. https://nostarch.com/assembly2.htm. "The concept of an interrupt is something that has expanded in scope over the years. The 80x86 family has only added to the confusion surrounding interrupts by introducing the int (software interrupt) instruction. Indeed different manufacturers have used terms like exceptions faults aborts traps and interrupts to describe the phenomena this chapter discusses. Unfortunately there is no clear consensus as to the exact meaning of these terms. Different authors adopt different terms to their own use. While it is tempting to avoid the use of such misused terms altogether for the purpose of discussion it would be nice to have a set of well defined terms we can use in this chapter. Therefore we will pick three of the terms above interrupts traps and exceptions and define them. This chapter attempts to use the most common meanings for these terms but don't be surprised to find other texts using them in different contexts." 
  2. "The Jargon File, version 4.4.7". 2003-10-27. http://catb.org/esr/jargon/html/T/trap.html. 
  3. "handler.apply() - JavaScript MDN". https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply.