Jump to ID:
QNX Operating System

Project Home

Documents

Discussions

Wiki

Project Info
Forum Topic - ClockCycles Misbehaving: Page 1 of 12 (12 Items)
   
 
 
ClockCycles Misbehaving  
Hello,

I am seeing some weird behavior when I run ClockCycles tightly in a loop. ClockCycles should always return increasing 
values, but sometimes it returns a value that's less than the previously returned value.

For example - 

	ThreadCtl(_NTO_TCTL_RUNMASK,(int*) 0x1);
	perror(NULL);

	start = ClockCycles();
	while(1)
	{
		stop = ClockCycles();

		if(start > stop)
		{
			diff = start - stop;
			printf("??? start-%llu, stop-%llu,diff-%llu, iteration - %d\n",start,stop,diff,iter);
			break;
		}
		start = stop;
		iter++;
	}


The iteration at which it happens is widely random. Ranging from 50 to 30000. 

Could this be because of a wrong setup in init_qtime.c inside startup code ?