中断处理函数中不用disable_irq而用disable_irq_nosync原因
来源:互联网 发布:我国网络支付平台 编辑:程序博客网 时间:2024/06/05 19:03
/**
* disable_irq_nosync - disable an irq without waiting
* @irq: Interrupt to disable
*
* Disable the selected interrupt line. Disablesand Enables are
* nested.
* Unlike disable_irq(),this function doesnot ensure existing
* instances of the IRQ handler have completed before returning.
*
* This function may be called from IRQ context.
*/
void disable_irq_nosync(unsigned int irq)
{
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
if (!desc)
return;
chip_bus_lock(irq, desc);
spin_lock_irqsave(&desc->lock, flags);
__disable_irq(desc, irq, false);
spin_unlock_irqrestore(&desc->lock, flags);
chip_bus_sync_unlock(irq, desc);
}
/**
* disable_irq - disable an irq and wait for completion
* @irq: Interrupt to disable
*
* Disable the selected interrupt line. Enables and Disables are
* nested.
* This function waits for any pending IRQ handlers for this interrupt
* to complete before returning. If you use this function while
* holding a resource the IRQ handler may need you will deadlock.
*
* This function may be called - with care - from IRQ context.
*/
void disable_irq(unsignedint irq)
{
struct irq_desc *desc = irq_desc + irq;
if (irq>= NR_IRQS)
return;
disable_irq_nosync(irq);
if (desc->action)
synchronize_irq(irq);
}
/**
* synchronize_irq - wait for pending IRQ handlers (on other CPUs)
* @irq: interrupt number to wait for
*
* This function waits for any pending IRQ handlers for this interrupt
* to complete before returning. If you use this function while
* holding a resource the IRQ handler may need you will deadlock.
*
* This function may be called - with care - from IRQ context.
*/
void synchronize_irq(unsignedint irq)
{
struct irq_desc *desc= irq_to_desc(irq);
unsigned int status;
if (!desc)
return;
do {
unsigned long flags;
/*
* Wait until we're out of the critical section. This might
* give the wrong answer due to the lack of memory barriers.
*/
while (desc->status& IRQ_INPROGRESS)
cpu_relax();
/* Ok, that indicated we're done: double-check carefully. */
spin_lock_irqsave(&desc->lock, flags);
status = desc->status;
spin_unlock_irqrestore(&desc->lock, flags);
/* Oops, that failed? */
} while (status & IRQ_INPROGRESS);
/*
* We made sure that no hardirq handler is running. Now verify
* that no threaded handlers are active.
*/
wait_event(desc->wait_for_threads,!atomic_read(&desc->threads_active));
}
注释中说明该函数是在等待中断处理程序的结束, 这也是disable_irq与disable_irq_nosync不同的主要所在. 但是在中断处理函数中调用会发生什么情况呢? 进入中断处理函数前IRQ_INPROGRESS会被__setup_irq设置, 所以程序会一直陷在while循环中, 而此时内核以经被独占, 这就导致系统死掉.
由于在disable_irq中会调用synchronize_irq函数等待中断返回, 所以在中断处理程序中不能使用disable_irq, 否则会导致cpu被synchronize_irq独占而发生系统崩溃.
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- 中断处理函数中不用disable_irq而…
- 中断处理函数中不用disable_irq而…
- 中断处理程序中的关中断函数disable_irq和disable_irq_nosync
- 关于中断处理程序中的关中断函数disable_irq和disable_irq_nosync
- 关于中断处理程序中的关中断函数disable_irq和disable_irq_nosync
- 关于中断处理程序中的关中断函数disable_irq和disable_irq_nosync
- 关于中断处理程序中的关中断函数disable_irq和disable_irq_nosync
- 关于中断处理程序中的关中断函数disable_irq和disable_irq_nosync
- 关于中断处理程序中的关中断函数disable_irq和disable_irq_nosync
- Hadoop Streaming Input and Output
- Mongoose源码剖析:外篇之web服务器
- 通向架构师的道路(第五天)之tomcat集群-群猫乱舞
- Centos 同步时间
- Android UI学习 - TableLayout
- 中断处理函数中不用disable_irq而用disable_irq_nosync原因
- Ubutnu下arm-linux-gcc交叉编译环境的搭建64位和32位都能用
- winform 修改系统日期
- Log4j基础入门(二)
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- DIV+CSS与不同IE版本等的兼容性
- [技术讨论]网络软件开发的bug分析与公司开发管理问题之腾讯篇二(有更新)
- Hoj 1316 Human Gene Functions
- 公钥加密体制