On Tue, Dec 04, 2001, Dan Kenigsberg wrote about "[Slightly Off Topic] processor 
speed":
> I would like to tell the speed of the processor I'm using, via a system call, on
>...
> Please assume I cannot open the computer or afraid of screwdrivers, 
> and cannot parse the lovely Linux /proc/cpuinfo, nor parse the output of Sun's

I'll answer only about Linux (I don't remember how to do this on Solaris).

On Linux, it is an "official" decision that instead of having dozens of system
calls, or weird non-standard system calls returning even weirder data
structures, or weird special kernel interfaces ("routing sockets" anyone?)
that simple kernel information like that will only be available through
the /proc/cpuinfo interface. What's wrong with that - how hard is to open
this file and look for a newline followed by "cpu MHz"?
The format of this file might changed in some future Linux release (the
linux-kernel mailing list is always filled with fights on how to change /proc),
but CPU speed is very non-portable anyway, so I don't see what problems this
can cause you.

Of course, it's possible to access the CPU directly and find the CPU's
version string, but this is definitely not recommended (if at all possible)
to do outside the kernel. Check the Linux kernel on how they do it, if you're
interested.

P.S. Obviously, with today's complicated CPUs, it is not at all certain how
exactly the MHz or bogomips figures in /proc/cpuinfo are relevant to the
"speed" of an actual program that you intend to run...

-- 
Nadav Har'El                        |     Tuesday, Dec  4 2001, 20 Kislev 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |I couldn't think of an interesting
http://nadav.harel.org.il           |signature to put here... Maybe next time.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to