Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1139187
  • 博文数量: 196
  • 博客积分: 4141
  • 博客等级: 中将
  • 技术积分: 2253
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-21 20:04
文章存档

2019年(31)

2016年(1)

2014年(16)

2011年(8)

2010年(25)

2009年(115)

分类: LINUX

2009-08-24 18:11:37

讨论网址:

In my opinion, it may occur that in the same irq_handlers entry(for
example irq_handlers[5]), two or more hooks have the same id:

/
*=============================
==============================================*
 *                              put_irq_handler                              *

*===========================================================================*/
PUBLIC void put_irq_handler(hook, irq, handler)
irq_hook_t *hook;
int irq;
irq_handler_t handler;
{
/* Register an interrupt handler. */
 int id;
 irq_hook_t **line;

 if (irq < 0 || irq >= NR_IRQ_VECTORS)
     panic("invalid call to put_irq_handler", irq);

 line = &irq_handlers[irq];
 id = 1;
 while (*line != NULL) {
     if (hook == *line) return;        /* extra initialization */
     line = &(*line)->next;
     id <<= 1;
 }
 if (id == 0) panic("Too many handlers for irq", irq);

 hook->next = NULL;
 hook->handler = handler;
 hook->irq = irq;
 hook->id = id;
 *line = hook;

 irq_use |= 1 << irq;
}

/
*===========================================================================*
 *                              rm_irq_handler                               *

*===========================================================================*/
PUBLIC void rm_irq_handler(hook)
irq_hook_t *hook;
{
/* Unregister an interrupt handler. */
 int irq = hook->irq;
 int id = hook->id;
 irq_hook_t **line;

 if (irq < 0 || irq >= NR_IRQ_VECTORS)
     panic("invalid call to rm_irq_handler", irq);

 line = &irq_handlers[irq];
 while (*line != NULL) {
     if ((*line)->id == id) {
         (*line) = (*line)->next;
         if (! irq_handlers[irq]) irq_use &= ~(1 << irq);
         return;
     }
     line = &(*line)->next;
 }
 /* When the handler is not found, normally return here. */
}

put_irq_handler(hook, 5, handler);
put_irq_handler(hook, 5, handler);
put_irq_handler(hook, 5, handler);
put_irq_handler(hook, 5, handler);
put_irq_handler(hook, 5, handler);
rm_irq_handler(hook);                                          //(hook->irq == 5, hook->id == 0x2)
put_irq_handler(hook, 5, handler);

if we
call the put_irq_handler five times continues, there will be five
hooks in the irq_handlers[5], and ids will be 0x1 0x2 0x4 0x8 0x10
respectively,
then call rm_irq_handler(hook), four hooks in the irq_handlers[5], ids
0x1 0x4 0x8 0x10,
then call put_irq_handler(hook, 5, handler); ids: 0x1 0x40 0x80 0x10
0x10

in the case, if we call rm_irq_handler(hook)((hook->irq == 5, hook->id
== 0x10)), which hook we should delete.

阅读(1740) | 评论(0) | 转发(0) |
0

上一篇:Lguest总结

下一篇:Jogging Trails(旅行商问题)

给主人留下些什么吧!~~