MPC8xx: resolution of gettimeofday() ?

Eugene Surovegin ebs at ebshome.net
Fri May 19 02:48:12 EST 2006


On Thu, May 18, 2006 at 05:10:40PM +0200, Steven Scholz wrote:
> Hi all,
> 
> what is the resolution of gettimeofday() for an MPC8xx?
> 
> IIUC then the "decrementer" is used to generate the timer interrupts every 10ms.
> 
> This decrementer runs at cpuclk/16. Thus with 80MHz CPU clock has a
> resolution of 16/80MHz = 200ns and overflows every 50000 ticks.
> 
> But is this decrementer used to update xtime?
> Will gettimeofday() have a resolution of 200ns?
> 
> How about linux 2.4 where xtime is a "struct timeval" rather then "struct
> timespec"?
> 
> This trivial test programm
> 
> 	struct timeval first, next;
> 	double diff;
> 
> 	gettimeofday(&first, NULL);
> 	do {
> 		gettimeofday(&next, NULL);
> 	} while (first.tv_usec == next.tv_usec &&
> 		 first.tv_sec == next.tv_sec);
> 
> 	diff  = ((double)  next.tv_sec - (double) first.tv_sec) * 1e6;
> 	diff +=  (double) (next.tv_usec - first.tv_usec);
> 
> 	printf ("Resolution gettimeofday() = %g ?s\n", diff);
> 
> says it's between 13 - 16 ?s on a linux-2.4.20. Could that be? how does this
> relate to the decrementer frequency?

Usually on PPC we use timebase to interpolate time between Decrementer 
interrupts. In this case gettimeofday resolution is determined by 
timebase resolution which is quite high (megahertz range).

-- 
Eugene




More information about the Linuxppc-embedded mailing list