zoukankan      html  css  js  c++  java
  • Difference between software interrupt, exception, trap

    Definition and difference between Hardware interrupt, Software Interrupt, Exception, Trap and Signals?

    Answer:

    Interrupts can be categorized into two groups which are asynchronous interrupts (aka interrupt, hardware interrupt) and synchronous interrupts (aka exception). The former may arrive anytime, typically IO interrupts, the latter may only arrive after the execution of an instruction, for example when the cpu try to divide a number by 0 or a page fault. So that’s the difference between interrupts and exception.

    Exception includes trap, fault, abort.

    A trap is a kind of exceptions, whose main purpose is for debugging (eg. notify the debugger that an instruction has been reached).

    A software interrupt (aka Programmed Exceptions) occur at the request of the programmer. They are used to implement system calls. Software interrupt is a considered to be an exception (because they are synchronous). Note that as far as Linux is concerned, software interrupt are handled by the CPU as trap so you might see somewhere else that system calls are implemented by trap.

    Signals (or at least UNIX signals) are part of the inter process communication (IPC). They are just like asynchronous message that one process can send to another one. So I would not consider them to be interrupt or exception.

    陷阱:由 trap 指令引起,恢复后 CPU 执行下一条指令(Debug point, system call)

    中断:由硬件电平引起,恢复后 CPU 执行下一条指令

    异常:由软件指令引起,恢复后 CPU 重新执行该条指令(Divide a number by 0 or a page fault)

     

    中断和异常有个比较大的共同点就是"不可预知性",所以是被迫的;而陷阱有"有意为之"的含义

    中断、异常和陷阱产生时都需要切换当前进程上下文进入中断处理程序(IDT table).

  • 相关阅读:
    [na][dhcp]华为DHCP-重要
    [na]win PPTP场景与搭建
    [na]锐起无盘机并发部署多台windows
    [na]wireshark抓包排错-tcp.flags.reset
    [svc]mousedos网络批量部署xp
    [na]诺顿ghost磁盘对刻(备份系统分区或数据分区)
    [na]代理arp导致的问题(路由卷)
    [na]pc加入域认证细节
    【VS开发】【智能语音处理】VS中声音的采集实现
    【VS开发】【智能语音处理】MATLAB 与 音频处理 相关内容摘记
  • 原文地址:https://www.cnblogs.com/sunkang/p/2038819.html
Copyright © 2011-2022 走看看