timer_list for FreeBSD?
Yong Ma
mayong at mail.com
Wed Nov 23 19:20:43 PST 2005
----- Original Message -----
From: "M. Warner Losh" <imp at bsdimp.com>
To: mayong at mail.com
Subject: Re: timer_list for FreeBSD?
Date: Wed, 23 Nov 2005 09:50:44 -0700 (MST)
>
> In message: <20051123092444.D826E164293 at ws1-4.us4.outblaze.com>
> "Yong Ma" <mayong at mail.com> writes:
> : In my work I send some data to the card and wait for a result in a
> : loop.but sometimes it can't get it ,so the driver run and run and
> : can't get out of the loop.I need something like timer_list in Linux
> : with which I can decide the max time the loop will run.I searched it
> : in the source code but found little about that.Anyone can help?
>
> Typically this sort of thing is done in FreeBSD in a more ad-hoc way:
>
> /*
> * Wait at most 1ms for the busy bit to flip. Datasheet
> * says it will take up to 250us, so add a sane margin of
> * error in case they are wrong. Note: GetStatus takes 1us
> * to perform the i/o.
> */
> limit = 1000;
> while ((GetStatus() & BusyBit) && limit-- > 0)
> continue;
>
> There's no easy API that will let you limit it to a fixed time. The
> above typically is sufficient for 'don't loop forever' so nothing
> fancier has been created.
>
> Warner
Thank you!
I tryed to make it with sleep(),but failed:
...
#include <unistd.h>
...
sec=10; //wait for ten seconds
while(GetStatus() && sec-->0){
dosomething();
sleep(1);
}
...
complied successfully and made the xxx.ko,but when kldload ./xxx.ko it told me can't load,I don't know why!
Yong
--
___________________________________________________
Play 100s of games for FREE! http://games.mail.com/
More information about the freebsd-drivers
mailing list