Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Problem with ClockCycles: (2 Items)
   
Problem with ClockCycles  
I'm trying to measure the tick overhead in a Beagleboard-XM-REV C. That uses an arm processor.
I get a problem when using the ClockCycles() system call, because the counter seems to start counting backward when I 
reduce the tick period.

I've made the following code to confirm this situation:

int main(int argc, char *argv[]) {

	_uint64 before_clkper, after_clkper;
	float cpu_freq;
	struct _clockperiod clkper;

	{
		struct sched_param param;
		int ret;
		param.sched_priority = sched_get_priority_max( SCHED_RR );
		ret = sched_setscheduler( 0, SCHED_RR, ¶m);
		assert ( ret != -1 );
	}
	cpu_freq = SYSPAGE_ENTRY( qtime )->cycles_per_sec;
	printf("Frequency of ClockCycles: %f\n", cpu_freq);
	
	clkper.nsec = 10000000;
	clkper.fract = 0;
	ClockPeriod ( CLOCK_REALTIME, &clkper, NULL, 0 );


	clkper.nsec = 10000;
	clkper.fract = 0;
	before_clkper= ClockCycles();
	ClockPeriod ( CLOCK_REALTIME, &clkper, NULL, 0 );
	after_clkper= ClockCycles();
	printf("Before clock period %lld. After clock period %lld\n", before_clkper, after_clkper);
	printf("Difference between clock period %lld\n", after_clkper-before_clkper);
	return 0;
}

The results were:

Frequency of ClockCycles: 13000000.000000
Before clock period 15088465604. After clock period 15088465368
Difference between clock period -236

Re: Problem with ClockCycles  
What is the overhead of the ClockCycles() call?
eg. delta between 2 back-to-back ClockCycles()?

The code uses an emulation that traps into the kernel and calls
the BSP timer_value() callout to calculate a delta from the last
clock. The clock tick handler maintains a 64-bit counter that is
incremented by qtime->timer_load so that ClockCycles returns:
counter + qtime->timer_value()

On 12-05-25 2:31 PM, Bruno Silva wrote:
> I'm trying to measure the tick overhead in a Beagleboard-XM-REV C. That uses an arm processor.
> I get a problem when using the ClockCycles() system call, because the counter seems to start counting backward when I 
reduce the tick period.
>
> I've made the following code to confirm this situation:
>
> int main(int argc, char *argv[]) {
>
> 	_uint64 before_clkper, after_clkper;
> 	float cpu_freq;
> 	struct _clockperiod clkper;
>
> 	{
> 		struct sched_param param;
> 		int ret;
> 		param.sched_priority = sched_get_priority_max( SCHED_RR );
> 		ret = sched_setscheduler( 0, SCHED_RR,¶m);
> 		assert ( ret != -1 );
> 	}
> 	cpu_freq = SYSPAGE_ENTRY( qtime )->cycles_per_sec;
> 	printf("Frequency of ClockCycles: %f\n", cpu_freq);
> 	
> 	clkper.nsec = 10000000;
> 	clkper.fract = 0;
> 	ClockPeriod ( CLOCK_REALTIME,&clkper, NULL, 0 );
>
>
> 	clkper.nsec = 10000;
> 	clkper.fract = 0;
> 	before_clkper= ClockCycles();
> 	ClockPeriod ( CLOCK_REALTIME,&clkper, NULL, 0 );
> 	after_clkper= ClockCycles();
> 	printf("Before clock period %lld. After clock period %lld\n", before_clkper, after_clkper);
> 	printf("Difference between clock period %lld\n", after_clkper-before_clkper);
> 	return 0;
> }
>
> The results were:
>
> Frequency of ClockCycles: 13000000.000000
> Before clock period 15088465604. After clock period 15088465368
> Difference between clock period -236
>
>
>
>
>
> _______________________________________________
>
> OSTech
> http://community.qnx.com/sf/go/post93305
> To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com