Subject: ltsleep while cold
To: None <tech-kern@NetBSD.org>
From: Martin Husemann <martin@duskware.de>
List: tech-kern
Date: 02/02/2005 21:14:23
What is the prefered way to do a delay for code that (might) run(s) during
autoconfiguration? The case at hand is dev/sun/kbsun.c that needs to wait
for the keyboard to reset before reading the keyboard type. It uses
this code:
/* the wakeup for this is in kbd_was_reset(). */
error = tsleep((caddr_t)&ks->kbd_id, PZERO | PCATCH, devopn, hz);
While cold, the (l)tsleep does only bounce spl to give interrupts a chance,
but does not cause any serious delay.
Now there are several ways to work around/fix this:
1) remove the wakeup, adjust spl() and just turn the tsleep into a delay(),
then restore spl.
2) change the wakeup into some flag setting and do a loop
around short delay() calls, adjusting spl before and after
as above
3) change ltsleep() for the cold case and insert a delay if it's timo
arg is non-zero
4) make ltsleep realy work, even if cold (using a global flag and
a loop around short delays, and having wakeup set the global flag)
Any thoughts?
Martin
(Thanks to John for analyzing the problem)