LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1704|回复: 1

about c

[复制链接]
发表于 2002-6-29 00:53:59 | 显示全部楼层 |阅读模式
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指针也被放掉,这不是很危险吗?
 楼主| 发表于 2002-6-29 09:00:19 | 显示全部楼层
Boss starcraft,if you are free,please help me.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表