[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 [EMAIL PROTECTED] for PGP public key
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message