zoukankan      html  css  js  c++  java
  • LKD: Chapter 7 Interrupts and Interrupt Handlers

      Recently I realized my English is still far from good. So in order to improve my English, I must not only read in English, but also think and write in English. I know I'm gonna make a lot of mistake in using English, but everything has a process so I just need to keep practiing my English.

      I use 2.6.34 instead of 2.6.32 as the book describes.

      There're two similar concepts:

    Exceptions: synchronous interrupts generated by the processor.

    Interrupts: asynchronous interrupts generated by hardware.

      In this chapter, we focus on the interrupts.

      Interrupt handlers are running in interrupt context, which cannot block.

      The processing of interrupts is split into two parts, or halves: 

    Top Half(interrupt handler): time-critical

    Bottom Half: deferred work.

    Resgitering an Interrupt Handler(P116):  

    /*     <linux/interrupt.h>     */
    int request_irq ( unsigned int irq,      /* interrupt number */
                      irq_handler_t handler,   /* function pointer to the actual interrupt handler */
               unsigned long flags,    /* can be either zero or a bit mask */
               const char *name,      /* an ASCII text representation of the device */
               void *dev)          /* used for shared interrupt lines */

      The third parameter, flags: IRQF_DISABLED, IRQF_SAMPLE_RANDOM, IRQF_TIMER, IRQF_SHARED.

    Freeing an Interrupt Handler:

    void free_irq (unsigned int irq, void *dev)

      A call to free_irq() must be made from process context.

    Writing an Interrupt Handler:

      The following is a declaration of an interrupt handler:

    static irqreturn_t intr_handler ( int irq, void *dev)

      An interrupt handler return two special value:

    IRQ_NONE: when the interrupt handler detects an interrupt for which its device was not the originator.

    IRQ_HANDLED: the interrupt handler was correctly invoked, and its device did indeed cause the interrupt.

  • 相关阅读:
    HTTP压力测试工具apache的ab的使用方法
    [转]Memcached 协议中英文对照
    [转]Windows下删除.svn文件夹的最简易方法
    [转]50 个便利的 Web 设计工具
    Navicat数据存放位置和备份数据库路径设置
    Silverlight第三方控件
    MVC3.0中使用JQuery.DataTable插件。
    什么是句柄?为什么会有句柄?HANDLE
    WPF内存释放
    ArcGis for wpf 符号渲染
  • 原文地址:https://www.cnblogs.com/justforfun12/p/5063518.html
Copyright © 2011-2022 走看看