Date: Wed, 23 Nov 2005 22:20:41 -0500 From: "Yong Ma" <mayong@mail.com> To: "M. Warner Losh" <imp@bsdimp.com> Cc: freebsd-drivers@freebsd.org Subject: Re: timer_list for FreeBSD? Message-ID: <20051124032041.CE1F31F50DE@ws1-2.us4.outblaze.com>
next in thread | raw e-mail | index | archive | help
----- Original Message ----- From: "M. Warner Losh" <imp@bsdimp.com> To: mayong@mail.com Subject: Re: timer_list for FreeBSD? Date: Wed, 23 Nov 2005 09:50:44 -0700 (MST) >=20 > In message: <20051123092444.D826E164293@ws1-4.us4.outblaze.com> > "Yong Ma" <mayong@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? >=20 > Typically this sort of thing is done in FreeBSD in a more ad-hoc way: >=20 > /* > * 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 =3D 1000; > while ((GetStatus() & BusyBit) && limit-- > 0) > continue; >=20 > 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. >=20 > Warner Thank you! I tryed to make it with sleep(),but failed: =20 ... #include <unistd.h> ... sec=3D10; //wait for ten seconds while(GetStatus() && sec-->0){ dosomething(); sleep(1); } ... complied successfully and made the xxx.ko,but when kldload ./xxx.ko it tol= d me can't load,I don't know why! Yong --=20 ___________________________________________________ Play 100s of games for FREE! http://games.mail.com/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051124032041.CE1F31F50DE>