Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: Andy Fong <andy@techsource.com>
Subject: Sleep and interrupt problem?
Date: Thu, 24 Mar 2005 16:08:47 -0500	[thread overview]
Message-ID: <pan.2005.03.24.21.08.44.966482@techsource.com> (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


                 reply	other threads:[~2005-03-24 21:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox