Calling tsleep(9) with interrupts disabled
Ian Lepore
freebsd at damnhippie.dyndns.org
Tue May 8 16:07:21 UTC 2012
I just realized that I've accidentally coded a sequence similar to this
in a driver:
s = intr_disable();
// do stuff here
tsleep(sc, 0, "twird", hz / 4);
// more stuff
intr_restore(s);
Much to my surpise this works, including waking up due to wakeup(sc)
being called from an interrupt handler. So apparently tsleep() results
in interrupts being re-enabled during the sleep, although nothing in the
manpage says that will happen.
Can I safely rely on this behavior, or is it working by accident?
(Please no lectures on the evils of disabling interrupts... This is not
a multi-GHz multi-core Xeon, it's a 180mhz embedded SoC with buggy
builtin devices that will drop or corrupt data if an interrupt happens
during the "do stuff here" part of the code.)
-- Ian
More information about the freebsd-hackers
mailing list