比较类似术语之间的差异

Difference Between

Home / Technology / IT / Systems /Difference Between Interrupt and Trap

Difference Between Interrupt and Trap

2011年6月27日Posted byIndika

中断与陷阱

In any computer, during its normal execution of a program, there could be events that can cause the CPU to temporarily halt. Events like these are called interrupts. Interrupts can be caused by either software or hardware faults. Hardware interrupts are called (simply) Interrupts, while software interrupts are called Exceptions or Traps. An Exception is an automatically generated software interrupt, while a Trap is a software-invoked interrupt initiated by the programmer. Once an interrupt (software or hardware) is raised, the control is transferred to a special subroutine called ISR (Interrupt Service Routine) that can handle the conditions that are raised by the interrupt.

什么是中断?

该术语中断通常用于硬件中断.They are program control interruptions caused by external hardware events. Here, external means external to the CPU.Hardware interrupts usually come from many different sources such as timer chip, peripheral devices (keyboards, mouse, etc.), I/O ports (serial, parallel, etc.), disk drives, CMOS clock, expansion cards (sound card, video card, etc). That means hardware interrupts almost never occur due to some event related to the executing program. For example, an event like a key press on the keyboard by the user, or an internal hardware timer timing out can raise this kind of interrupt and can inform the CPU that a certain device needs some attention. In a situation like that the CPU will stop whatever it was doing (i.e. pauses the current program), provides the service required by the device and will get back to the normal program. When hardware interrupts occur and the CPU starts the ISR, other hardware interrupts are disabled (e.g. in 80×86 machines). If you need other hardware interrupts to occur while the ISR is running, you need to do that explicitly by clearing the interrupt flag (withstiinstruction). In 80×86 machines, clearing the interrupt flag will only affect hardware interrupts.

What is a Trap?

A Trap can be identified as a transfer of control, which is initiated by the programmer. The term Trap is used interchangeably with the term Exception (which is an automatically occurring software interrupt). But some may argue that a trap is simply a special subroutine call. So they fall in to the category of software-invoked interrupts. For example, in 80×86 machines, a programmer can use theintinstruction to initiate a trap. Because a trap is always unconditional the control will always be transferred to the subroutine associated with the trap. The exact instruction, which invokes the routine for handling the trap is easily identified because an explicit instruction is used to specify a trap.

What is the difference between Interrupt and Trap?

Interrupts are hardware interrupts, while traps are software-invoked interrupts. Occurrences of hardware interrupts usually disable other hardware interrupts, but this is not true for traps. If you need to disallow hardware interrupts until a trap is served, you need to explicitly clear the interrupt flag. And usually the interrupt flag on the computer affects (hardware) interrupts as opposed to traps. This means that clearing this flag will not prevent traps. Unlike traps, interrupts should preserve the previous state of the CPU.

Related posts:

系统呼叫和中断之间的区别 Difference Between Interrupt and Exception Difference Between Exception and Error Difference Between System Call and Function Call 英特尔酷睿i3的区别nd 2nd Generation Intel Core i3 Processors

Filed Under:SystemsTagged With:自动软件中断,异常,异常s,Hardware interrupt,interrupt,interrupt flag,interrupts,ISR,program execution,software interrupt,software-invoked interrupt,子例程呼叫,trap,Traps

About the Author:Indika

Indika, BSc.Eng, MSECE Computer Engineering, PhD. Computer Science, is an Assistant Professor and has research interests in the areas of Bioinformatics, Computational Biology, and Biomedical Natural Language Processing.

发表评论Cancel reply

Your email address will not be published.Required fields are marked*

Request Article

Featured Posts

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and SARS

Difference Between Coronavirus and SARS

冠状病毒和流感的差异

冠状病毒和流感的差异

Difference Between Coronavirus and Covid 19

Difference Between Coronavirus and Covid 19

You May Like

Difference Between Digital Marketing and Traditional Marketing

Difference Between Digital Marketing and Traditional Marketing

Difference Between Liner and Shader Tattoo Gun

然而,尽管如此

Difference Between Kanpur and Lucknow

Difference Between ERD and DFD

Latest Posts

  • What is the Difference Between Functional and Performance Ingredients
  • What is the Difference Between Intracerebral Hemorrhage and Subarachnoid Hemorrhage
  • 氯化苯甲酸盐和甲硫酸苯二硫酸盐的区别是什么
  • What is the Difference Between Systolic and Diastolic Dysfunction
  • What is the Difference Between Care and Concern
  • Ehlers Danlos和Marfan综合征有什么区别
  • Home
  • Vacancies
  • About
  • Request Article
  • 联系我们

Copyright © 2010-2018Difference Between. All rights reserved.Terms of Use和隐私政策:Legal.