Changing clock speed

Bruce Guenter (bruce.guenter@qcc.sk.ca)
Mon, 22 Feb 1999 12:32:34 -0600


Greetings.

As I was trying to track down a problem with the clock on a router
behaving erratically, I ran a simple loop benchmark repeatedly and
observed that the time taken to run the loop varied by a factor of four.
I've attached a copy of the trivial code I've been using as a test. The
output that I'm seeing is similar to the following:
2.466084 elapsed
2.462390 elapsed
2.465988 elapsed
2.462941 elapsed
2.462379 elapsed
2.466217 elapsed
4.412072 elapsed
9.974608 elapsed
9.977335 elapsed
9.971237 elapsed
9.974362 elapsed
9.977291 elapsed
9.981226 elapsed
9.975351 elapsed
9.979276 elapsed
9.979474 elapsed
10.414870 elapsed
9.976333 elapsed
9.983979 elapsed
7.820407 elapsed
2.465433 elapsed
2.464025 elapsed
2.465426 elapsed
2.463496 elapsed
2.470637 elapsed
2.467717 elapsed
2.470983 elapsed
2.466418 elapsed
There are no other processes running on this that would consume
significant amounts of CPU time. It is a AMD K6 at 233MHz routing
between three relatively 10Base Ethernet networks, running the 2.0.36
kernel (as compiled by RedHat :-).

Is there a problem with my methodology, or is there something really odd
going on with this computer?

-- 
Bruce Guenter, QCC Communications Corp.  EMail: bruce.guenter@qcc.sk.ca
Phone: (306)249-0220               WWW: http://www.qcc.sk.ca/~bguenter/

#include <stdio.h> #include <sys/mman.h> #include <sys/time.h> #include <unistd.h>

void loop() { int i; for(i = 0; i < 28733835*10; i++); }

void showtime(struct timeval* tv1, struct timeval* tv2) { long usec, sec; usec = tv2->tv_usec - tv1->tv_usec; sec = tv2->tv_sec - tv1->tv_sec; if(usec < 0) { usec += 1000000; sec --; } printf("%d.%06d elapsed\n", sec, usec); }

int main() { mlockall(MCL_FUTURE); for(;;) { struct timeval tv1, tv2; gettimeofday(&tv1, 0); loop(); gettimeofday(&tv2, 0); showtime(&tv1, &tv2); } return 0; }

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/