Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jul 1999 10:00:45 +0930
From:      Greg Lehey <grog@lemis.com>
To:        Jeff Hagendaz <jeffhdz@my-Deja.com>
Cc:        FreeBSD Hackers <hackers@freebsd.org>
Subject:   Re: polling in device driver
Message-ID:  <19990722100045.I84734@freebie.lemis.com>
In-Reply-To: <BALPOCGFGEOOBAAA@my-deja.com>; from Jeff Hagendaz on Wed, Jul 21, 1999 at 04:20:48PM -0700
References:  <BALPOCGFGEOOBAAA@my-deja.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[returning to -hackers]

On Wednesday, 21 July 1999 at 16:20:48 -0700, Jeff Hagendaz wrote:
> Hi,
>
> I asked this in -hackers, but didn't get an answer.
> Guess it is too simple to quanlify into -hackers,
> I am moving it here.  Your help is highly appreciated.

No, -hackers is the right place.  Just because you don't get an answer
doesn't mean that you posted in the wrong place :-)

> I am reading a Linux device driver.  At some point it
> polls a device to check if it is ready.  The timeout
> is set to 5 second.  It uses the system jiffies to
> count the time:
>
>     u32 time_out = jiffies + 5 * HZ;
>     for (;;) {
>         /* code to check if dev is ready */
>         ........
>         if (ready) break;
>         if (intr_count == 0) schedule();
>         if (jiffies > time_out) return ERROR;
>     }
>
> How do I implement such polling in FreeBSD?  Thanks.

If at all possible, you don't.  If it's in the bottom half, you don't.
You should try to find a better way to find when the device is ready:
the driver appears to be counting interrupts, so you can probably
tsleep for 5 seconds and wakeup from the lower half when you get an
interrupt.  It's difficult to give an example from the code you show.

Greg
--
When replying to this message, please copy the original recipients.
For more information, see http://www.lemis.com/questions.html
See complete headers for address, home page and phone numbers
finger grog@lemis.com for PGP public key


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990722100045.I84734>