synchronization question about /sys/dev/vkbd/vkbd.c

Norbert Koch NKoch at demig.de
Mon Jun 6 06:36:41 GMT 2005


> > My question is:
> > Is it not possible, that vkbd_dev_intr() could be
> > interrupted at any position before the VKBD_LOCK()
> > and then vkbd_dev_write() called?
> 
> in theory it is possible.
> 
> > If yes, how should vkbd_dev_write() know, that it should
> > call task_enqueue(), as TASK is still set?
> 
> well, i guess it is possible to miss interrupt in this case. also, the 
> scancodes are not lost, they will be processed on next write.
> 

I agree, that it is hardly possible to miss an interrupt, as keys
come in so slowly. But that also means if it happens, you will notice
it, because you have to press an additional key.

> i suspect that the vkbd_dev_intr() should be interrupted exactly 
> in between
> 
> (*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
> 
> and
> 
> VKBD_LOCK(state);
> 

Yes, precisely.

> yes, that could be done. it is also possible to have a callout going few 
> times a second to check if there is a scancodes in the queue and 
> schedule vkbd_dev_intr(). funny that atkbd(4) and ukbd(4) have just this.


Thank you for your comments,

Norbert


More information about the freebsd-hackers mailing list