On Jan 9, 2004, at 6:12 PM, Palle Girgensohn wrote:
How can I programatically find out the CPU frequency?
[ ... ]
Better ideas?

Here's a chunk of code from an old homework assignment from my days at CMU. :-)


http://www.pkix.net/~chuck/clockspeed/

This uses an iterative method to achieve results within a certain accuracy-- a few percent-- but it works as a normal user without requiring anything more than the standard Unix interval timers.

28-ns1% ./freq
The clock frequency is approximately 395 Megahertz

29-ns1% dmesg | head
Copyright (c) 1992-2003 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD 4.9-STABLE #9: Tue Dec 2 16:05:30 EST 2003
[EMAIL PROTECTED]:/usr/obj/usr/src/sys/NORMAL
Timecounter "i8254" frequency 1193182 Hz
CPU: Pentium II/Pentium II Xeon/Celeron (399.86-MHz 686-class CPU)
Origin = "GenuineIntel" Id = 0x652 Stepping = 2
Features=0x183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,C MOV,PAT,PSE36,MMX,FXSR>


--
-Chuck

_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to