/* TSC sync test * by: john stultz (johnstul@us.ibm.com) * (C) Copyright IBM 2003, 2005 * Licensed under the GPL */ #include #include #define CALLS_PER_LOOP 64 # define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val)) int main(int argc, char *argv[]) { unsigned long long list[CALLS_PER_LOOP]; int i, inconsistent; /* timestamp start of test */ system("date"); while(1){ inconsistent = 0; /* Fill list */ for(i=0; i < CALLS_PER_LOOP; i++) rdtscll(list[i]); /* Check for inconsistencies */ for(i=0; i < CALLS_PER_LOOP-1; i++) if(list[i] > list[i+1]) inconsistent = i+1; /* display inconsistency */ if(inconsistent){ inconsistent--; for(i=0; i < CALLS_PER_LOOP; i++){ if(i == inconsistent) printf("--------------------\n"); printf("%llu\n",list[i]); if(i == inconsistent + 1 ) printf("--------------------\n"); } fflush(0); /* timestamp inconsistency*/ system("date"); } } return 0; }