* Sleep and interrupt problem?
@ 2005-03-24 21:08 Andy Fong
0 siblings, 0 replies; only message in thread
From: Andy Fong @ 2005-03-24 21:08 UTC (permalink / raw)
I am writing a device driver. In some situation,
I need to go to sleep and wait for an interrupt to wake me up so
I don't use up the cpu cycles. Here is what I do:
If (operation not done yet) {
EnableInterrupt;
if (operation not done yet) {
tsleep for 1 second;
}
}
I run into problem where the sleep times out very often which
should never happen. I suspect that tsleep/sleep is not atomic
interrupt comes in after the sleep function call and before it
actually goes to sleep. I tried to take out the 2nd check and go
to sleep immediately after enabling the interrupt but it doesn't
help at all.
I can work around the problem by sleeping for 10 msec at a time
in a loop and break out the loop if the operation is done but
that not very efficient. Is there any way to do atomic sleep?
Thank you for any help.
Andy
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-03-24 21:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-24 21:08 Sleep and interrupt problem? Andy Fong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox