Accessing TSC Register

I'm accessing the TSC register, and using usleep() function to calculate my clock frequency. Basically, I check the current clock, delay for 1 second, and then check the clock again to discover how many clock ticks occur in a second.

The only problem is - my result turns out to be a ridiculous (and inconsistent) number. It always very close to one of the two following numbers.
18446744072127.2 Mhz or 2712.6 Mhz

My question - Is this a result of having a multi-core processor? Or is my code/logic just plain wrong? I included the relevant sections of the code below.

typedef unsigned long long int UINT64;

UINT64 startTSC = 0;
UINT64 stopTSC = 0;
UINT64 cycleCnt = 0;

// Access TSC register to get current value
__asm__ volatile(".byte 0x0f,0x31" : "=A" (startTSC));
// Delay for 1*10^6 us (1 second)
usleep(1000000);
// Access TSC register to get new value
__asm__ volatile(".byte 0x0f,0x31" : "=A" (stopTSC));

// Calculate cycles that happened over the full second
cycleCnt = stopTSC-startTSC;

TSC is in fact munged by dual or quad core systems, and also by power-saving features that change the CPU clock rate. In any event I'm not convinced your inline assembly is working, being raw hex there. I've found some source here with perhaps a better implementation:

/*
 * get_tsc()
 */
static unsigned long long get_tsc(void)
{
	unsigned long long tsc;
	__asm__ __volatile__ ("rdtsc" : "=A" (tsc));
	return tsc;
}

You may need to change 'long long' to just 'long' on 64-bit systems. Or better yet, #include <stdint.h> and use uint64_t for code that should work on both...