【linux kernel】 softirq 软中断讨论
欢迎转载,转载时需保留作者信息,谢谢。
博客园地址: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 软中断讨论的更多相关文章
- Linux kernel的中断子系统之(八):softirq
返回目录:<ARM-Linux中断系统>. 总结:中断分为上半部和下半部,上半部关中断:下半部开中断,处理可以延迟的事情.下半部有workqueue/softirq/tasklet三种方式 ...
- linux kernel的中断子系统 softirq
linux kernel的中断子系统之(八):softirq http://www.wowotech.net/irq_subsystem/soft-irq.html http://www.ibm.co ...
- Linux kernel的中断子系统之(六):ARM中断处理过程
返回目录:<ARM-Linux中断系统>. 总结:二中断处理经过两种模式:IRQ模式和SVC模式,这两种模式都有自己的stack,同时涉及到异常向量表中的中断向量. 三ARM处理器在感知到 ...
- Linux kernel的中断子系统之(九):tasklet
返回目录:<ARM-Linux中断系统>. 总结: 二介绍了tasklet存在的意义. 三介绍了通过tasklet_struct来抽想一个tasklet,每个CPU维护一个tasklet链 ...
- Linux中断 - softirq
一.前言 对于中断处理而言,linux将其分成了两个部分,一个叫做中断handler(top half),是全程关闭中断的,另外一部分是deferable task(bottom half),属于不那 ...
- Linux kernel中断子系统之(五):驱动申请中断API【转】
转自:http://www.wowotech.net/linux_kenrel/request_threaded_irq.html 一.前言 本文主要的议题是作为一个普通的驱动工程师,在撰写自己负责的 ...
- linux 中断softirq tasklet
硬中断为什么不能休眠--- 中断线程以及软中断解决了什么问题---- 软中断cb函数是否允许相应本地中断,什么时候开启中断关闭中断---- 什么是软中断上下文------- 什么是tasklet 和软 ...
- Intel 80x86 Linux Kernel Interrupt(中断)、Interrupt Priority、Interrupt nesting、Prohibit Things Whthin CPU In The Interrupt Off State
目录 . 引言 . Linux 中断的概念 . 中断处理流程 . Linux 中断相关的源代码分析 . Linux 硬件中断 . Linux 软中断 . 中断优先级 . CPU在关中断状态下编程要注意 ...
- Linux Kernel Synchronization && Mutual Exclusion、Linux Kernel Lock Mechanism Summarize
目录 . 内核锁机制 . 同步与互斥 . 锁定内存总线原子操作 . 信号量 . 自旋锁 . RCU机制 . PERCPU变量 . 内存和优化屏障 . 读者/写者锁 . 大内核锁 . 互斥量 1. 内核 ...
随机推荐
- php随笔6-thinkphp OA系统 JS 实时显示当前时间
不多说,直入主题: JS. // JavaScript Document function showtime() { var today,hour,second,minute,year,month,d ...
- PHP函数积累
1.mt_rand(min,max):随机返回min,max之间的随整数机数. 2.date('Y-m-d H:m:s',时间戳),将时间戳格式化为相应的时间格式.time()取得时间戳 3.arra ...
- Django内置template标签
html过滤{% autoescape on|off %} {{body}} {% endautoescape %} 注释{% comment %} {% endcomment %} csrf攻击 { ...
- CentOS 6.5系统安装配置图解教程(详细图文)
转载:http://www.jb51.net/os/128751.html
- Unable to connect to your virtual device!解决方法
使用Genymotion安卓模拟器的用户,很多朋友在启动安卓系统的时候就弹出了以下英文,不知道如何处理,今天电脑知识网小编来教您处理Genymotion安卓模拟器启动出错的问题. Error Unab ...
- 《Android第一行代码》笔记
学习Android开发差点儿相同有两年时间了.期间也做了大大小小的一些项目.近来抽出闲暇想把Android基础强化一下,之前在网上看到了郭霖郭大神的几篇博客.从中受益不少.于是花了近一周时间看完了郭神 ...
- 机器学习笔记(三)- from Andrew Ng的教学视频
week four: Non-linear hypotheses:Neural Networks -->x1 and x2 x1 XNOR x2 ->a1->x1 and x2;a2 ...
- Executor框架
Executor框架是指java5中引入的一系列并发库中与executor相关的功能类,包括Executor.Executors.ExecutorService.CompletionService. ...
- BufferedInputStream 源码分析
一.简介 BufferedInputStream会缓存一部分数据(默认8K),这个函数的作用就是读取更多的数据到缓存,必要的时候会扩大缓存的内容. 在该类中有几个重要的标志位:markpos,pos, ...
- 同步机制Lock初学(转)
前段时间review同事的代码,发现可以简化成如下的模型: Thread 1 Thread 2 lock.lock(); condition.await(); lock.unlock() lock.l ...