|
2.3.x-2.4.10kernel中的几句c源码.....
为防止不同的cpu同时对键盘朝作(多cpu系统中),请看:
[keyboard_interrupt()>handle_kdb_event()]
static unsigned charf handle_kbd_event(void)
{
unsigned char status=kdb_read_status();
unsigned int work=1000;
while((--work>0)&&(status & KBD_STAT_OBF){
unsigned char scancode;
scancode=kdb_read_input();
#if 1
if(!(status&(KBD_STAT_GTO|KDB_STAT_PERR)))
#endif {if(status & KDB_STAT_MOUSE_OBF)handle_keyboard_event(scancode);
else handle_keyboard_event(scancode);
}
status=kdb_read_status();
}
if(!work)printk(KERN_ERR "pc_keyb:controller jammed (0x%02X).\n",status);
return status;
}
kdb_controller_lock上了把锁以保互斥性
static void keyboard_interrupt(int irq,void *dev_id,struct pt_regs *regs)
{
#ifdef CONFIG
kdb_pt_regs=regs;
#endif
spin_lock_irq(&kdb_controller_lock);
handle_kdb_event();
spin_unlock_irq(&kdb_controller_lock);
}
我觉得在上父进程时,handle_kbd_event()会从keyboardinterrup()脱出,regs指针也被放掉,这不是很危险吗? |
|