On some systems the timebase runs at a rather low frequency, say 20MHz. This test will spuriously fail there. Waste a million CPU cycles beforereading TB the second time?Waste said million cycles portably by calling sched_yield()? (Available only on POSIX systems. :)
I was thinking more along the lines of int j; for (j = 0; j < 1000000; j++) asm("" : : "r"(j)); which is more portable (and a lot more predictable). Segher