欢迎转载,转载时需保留作者信息,谢谢。

邮箱:tangzhongp@163.com

博客园地址:http://www.cnblogs.com/embedded-tzp

Csdn博客地址:http://blog.csdn.net/xiayulewa

早看到这篇文章,就不写了,懒:

 Linux中断(interrupt)子系统之五:软件中断(softIRQ)http://blog.csdn.net/droidphone/article/details/7518428

1.1.  数据结构

struct softirq_action

{

    void    (*action)(struct softirq_action *);

};

 

²  static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;

 

softirq_vec是一个struct softirq_action数组,使用open_softirq注册

 

Softirq.c (src\kernel):52 中:

²  irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;

其操作:raise_softirq_irqoff→or_softirq_pending置位bitmap:irq_stat[cpu].__softirq_pending

 

1.2.  软中断注册

 

void open_softirq(int nr, void (*action)(struct softirq_action *))

{

    softirq_vec[nr].action = action;

}

不是链表结构。

 

可被注册的有

enum

{

    HI_SOFTIRQ=0,

    TIMER_SOFTIRQ,

    NET_TX_SOFTIRQ,

    NET_RX_SOFTIRQ,

    BLOCK_SOFTIRQ,

    BLOCK_IOPOLL_SOFTIRQ,

    TASKLET_SOFTIRQ,

    SCHED_SOFTIRQ,

    HRTIMER_SOFTIRQ,

    RCU_SOFTIRQ,    /* Preferable RCU should always be the last softirq */

 

    NR_SOFTIRQS

};

 

如在softirq_init中有open_softirq(TASKLET_SOFTIRQ, tasklet_action);

这说明 tasklet是被放入软中断中执行的。

1.3.  软中断执行流程

1.3.1.   路径1:

open_softirq注册→raise_softirq→raise_softirq_irqoff→raise_softirq_irqoff→wakeup_softirqd

在wakeup_softirqd中唤醒ksoftirqd进程,

 

static struct smp_hotplug_thread softirq_threads = {

    .store          = &ksoftirqd,

    .thread_should_run  = ksoftirqd_should_run,

    .thread_fn      = run_ksoftirqd,

    .thread_comm        = "ksoftirqd/%u",

};

 

执行.thread_fn = run_ksoftirqd  →__do_softirq

在 _do_softirq中有

h = softirq_vec;

……………………………

h->action(h); 即为具体注册函数

……………………………

 

Ksoftirqd:是个线程, 其流程为

start_kernel→rest_init→kernel_init→kernel_init_freeable

→do_basic_setup→do_initcalls→spawn_ksoftirqd

→smpboot_register_percpu_thread(&softirq_threads)

 

 

1.3.2.   路径2:

open_softirq注册→raise_softirq→raise_softirq_irqoff→raise_softirq_irqoff→irq_exit(在中断退出时执行)→invoke_softirq→do_softirq(或wakeup_softirqd) →__do_softirq→ h->action(h); 即为具体注册函数

 

 

【linux kernel】 softirq 软中断讨论的更多相关文章

  1. Linux kernel的中断子系统之(八):softirq

    返回目录:<ARM-Linux中断系统>. 总结:中断分为上半部和下半部,上半部关中断:下半部开中断,处理可以延迟的事情.下半部有workqueue/softirq/tasklet三种方式 ...

  2. linux kernel的中断子系统 softirq

    linux kernel的中断子系统之(八):softirq http://www.wowotech.net/irq_subsystem/soft-irq.html http://www.ibm.co ...

  3. Linux kernel的中断子系统之(六):ARM中断处理过程

    返回目录:<ARM-Linux中断系统>. 总结:二中断处理经过两种模式:IRQ模式和SVC模式,这两种模式都有自己的stack,同时涉及到异常向量表中的中断向量. 三ARM处理器在感知到 ...

  4. Linux kernel的中断子系统之(九):tasklet

    返回目录:<ARM-Linux中断系统>. 总结: 二介绍了tasklet存在的意义. 三介绍了通过tasklet_struct来抽想一个tasklet,每个CPU维护一个tasklet链 ...

  5. Linux中断 - softirq

    一.前言 对于中断处理而言,linux将其分成了两个部分,一个叫做中断handler(top half),是全程关闭中断的,另外一部分是deferable task(bottom half),属于不那 ...

  6. Linux kernel中断子系统之(五):驱动申请中断API【转】

    转自:http://www.wowotech.net/linux_kenrel/request_threaded_irq.html 一.前言 本文主要的议题是作为一个普通的驱动工程师,在撰写自己负责的 ...

  7. linux 中断softirq tasklet

    硬中断为什么不能休眠--- 中断线程以及软中断解决了什么问题---- 软中断cb函数是否允许相应本地中断,什么时候开启中断关闭中断---- 什么是软中断上下文------- 什么是tasklet 和软 ...

  8. Intel 80x86 Linux Kernel Interrupt(中断)、Interrupt Priority、Interrupt nesting、Prohibit Things Whthin CPU In The Interrupt Off State

    目录 . 引言 . Linux 中断的概念 . 中断处理流程 . Linux 中断相关的源代码分析 . Linux 硬件中断 . Linux 软中断 . 中断优先级 . CPU在关中断状态下编程要注意 ...

  9. Linux Kernel Synchronization && Mutual Exclusion、Linux Kernel Lock Mechanism Summarize

    目录 . 内核锁机制 . 同步与互斥 . 锁定内存总线原子操作 . 信号量 . 自旋锁 . RCU机制 . PERCPU变量 . 内存和优化屏障 . 读者/写者锁 . 大内核锁 . 互斥量 1. 内核 ...

随机推荐

  1. linux下面安装软件学习流程

    先不要急着配置LNMP 我相信你的LINUX基础一定很差,先去学LINUX. 基础最重要. 凡事都要先从基础搞起. 再把gcc搞搞. gcc的相关参数很多,多了解一下. 想要编译安装,不对gcc有些了 ...

  2. CSS3 transform制作的漂亮的滚动式导航

    模拟这个做的 不过实现的没有别人那么好 http://www.creativetier.com/products/modern-menu-3/vertical.html 关于transform  看这 ...

  3. QPushButton跑进度条(使用QSS的不同修饰来实现,其实是伪进度条)

    主要用到qlineargradient,写以下CSS样式即可实现: background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, sto ...

  4. Mac平台编译mupdf-qt的开源项目

    How to compile mupdf-qt Compile on Linux Install tools and thirdparty libraries You should install s ...

  5. "No appenders found for logger" and "Please configure log4j properly"

    Why do I see a warning about "No appenders found for logger" and "Please configure lo ...

  6. 高级爬虫工程师(Spider)-美团网-拉勾网-最专业的互联网招聘平台

    高级爬虫工程师(Spider)-美团网-拉勾网-最专业的互联网招聘平台 高级爬虫工程师(Spider)

  7. Google瓦片地图算法解析

    基本概念: 地图瓦片地址:http://mt2.google.cn/vt/lyrs=m@167000000&hl=zh-CN&gl=cn&x=420&y=193& ...

  8. JAE京东云引擎Git上传管理代码教程和京东云数据库导入导出管理

    文章目录 Git管理准备工作 Git工具上传代码 发布代码装程序 mywebsql管理 京东云引擎小结   JAE京东云引擎是京东推出的支持Java.Ruby.Python.PHP.Node.js多语 ...

  9. HDU 4734 F(x) 2013 ACM/ICPC 成都网络赛

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4734 数位DP. 用dp[i][j][k] 表示第i位用j时f(x)=k的时候的个数,然后需要预处理下小 ...

  10. Codeforces 455B A Lot of Games(字典树+博弈)

    题目连接: Codeforces 455B A Lot of Games 题目大意:给定n.表示字符串集合. 给定k,表示进行了k次游戏,然后是n个字符串.每局開始.字符串为空串,然后两人轮流在末尾追 ...