[uClinux-dev] usleep takes longer as expected
Siegfried Müller
mueller at mbconnectline.de
Mon Feb 4 11:46:43 EST 2008
Hi Harry,
that seems to be the right way. I'll try this.
thank you.
regards
Siegfried
-----Ursprüngliche Nachricht-----
Von: uclinux-dev-bounces at uclinux.org
[mailto:uclinux-dev-bounces at uclinux.org] Im Auftrag von Harry Gunnarsson
Gesendet: Montag, 4. Februar 2008 17:12
An: uClinux development list
Betreff: Re: [uClinux-dev] usleep takes longer as expected
Hi,
Are you using m68k?
If so, take a look at linux-2.6.x/include/asm-m68knommu/param.h.
You'll see a line
#define HZ 100
That's your resolution for delay-like calls in uClinux, including the
'usleep' call. In this case, it is set by default to 100Hz, i.e. 10ms
resolution.
I experimented by setting this to 1000, thus enabling 1ms resolution. It
seemed to work, usleep behaves as expected.
I read somewhere that one might need to change other things as well, but
that posting might have been obsolete. My system behaves well with just
the HZ change.
Observe the following though:
I measured a 15.46% larger overhead with the 100 to 1000 HZ change. (10
times more frequent tick in kernel, and there is a lot of code executed
with each tick) In my case, we figured we could live with it, since in
one certain situation we preferably wanted ~1ms resolution.
Regards,
Harry
On Feb 4, 2008 7:57 AM, Siegfried Müller <mueller at mbconnectline.de>
wrote:
Hi,
I work with the snapgear distro 3.4 and uClibc.
I use usleep to wait for an exact time, but usleep takes a minimum
of 10.000usec. If i use usleep(100) it takes 10.000usec. Why?
int main(int argc, char *argv[])
int i1=0;
struct timeval mytime;
struct timezone mytimezone;
while(i1 < 10){
gettimeofday(&mytime,&mytimezone);
printf("Test %d, usec=%d,
sec=%d\n",i1,mytime.tv_usec,mytime.tv_sec);
usleep(100);
i1++;
}
}
Does anyone has an idea?
Cheers
Siegfried
_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20080204/c52cb85e/attachment.html
More information about the uClinux-dev
mailing list