[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] usleep
Hi Jay, Yasshi,
Yasushi SHOJI wrote:
> At Mon, 25 Oct 2004 13:53:44 -0600,
> Jay Norrish wrote:
>>I am trying to use the usleep() function to
>>put my application to sleep while my peripherals
>>do data acquisition but, I have not been able to get
>>the function to have a resolution of less than 10ms
>>which is the tick rate.
A quick surf in the sources explains why - the usleep() lib call
translates to a nanosleep() syscall, which is implemented in the kernel
with a schedule_timeout(). At first glance, the only way you'll get a
wakeup before 10ms is if you are under heavy interrupt load from a ping
flood or similar.
It seems this is an established limitation of usleep. I see some
mailing list threads proposing ways to improve it etc, but none of these
have been implemented in microblaze.
>> I know I could change the tick rate
>>with the #define HZ in the mb_vannilla.h file but I am worried that it will
>>break other programs.
>
> I wouldn't recommend to change HZ for 2.4, if you don't know the
> kernel internal. it might or might not work.
Oh but it's definitely worth a try! ;-) Please let us know what
happens...
>>Is there another function or way to do this ?
>
> use bigger fifo and/or interrupt. even with those, timing is not
> guaranteed. Linux is not a realtime os after all.
Perhaps you might consider a sort of busy-wait loop with calls to
gettimeofday() - it offers near microsecond resolution. It's not very
friendly to other processes in the system, but if your wait is much
shorter than the tick interval (which it must be, otherwise usleep()
would suffice), then it mightn't matter too much.
Cheers,
John
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@itee.uq.edu.au
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/