On Wed, Nov 08, 2000, Adi Stav wrote about "Re: number of CPUs":
>...
> But why is it so crucial not to parse a file? I can't imagine anyone
> checking for the number of CPUs in the inner loop of their programs :)
>
> system( "exit `grep ^processor /proc/cpuinfo | tail -1 | cut -d : -f 2`" )
>
> Would probably work (I don't have SMP machine to check it).
This will obviously not work - unless your intention was to print the number
of processors on the standard output, rather than actually using it in
your program :)
The one-namespace idea of /proc was very good (probably taken from plan 9),
but in my opinion it wasn't done too well. We should have had a number of
different files for the different informations, e.g,
/proc/cpuinfo/ncpus
/proc/cpuinfo/1/model
...
and things like that. (just like you have for processes on /proc).
Alternatively, we should have a libary (say, liblinux.so) that has functions
that use the /proc interface to get this information. But I don't believe
such a library exists.
--
Nadav Har'El | Thursday, Nov 9 2000, 11 Heshvan 5761
[EMAIL PROTECTED] |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Promises are like babies: fun to make,
http://nadav.harel.org.il |but hell to deliver.
=================================================================
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]