[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: number of CPUs



On Tue, Nov 07, 2000 at 07:24:35PM +0200, Ely Levy wrote:
> I'll take that as a no?
> geezz..
> 
> 
> Ely Levy
> System group
> Hebrew University 
> Jerusalem Israel
> 
> 
> 
> On Mon, 6 Nov 2000, Adi Stav wrote:
> 
> |  On Mon, Nov 06, 2000 at 10:55:28PM +0200, Ely Levy wrote:
> |  > how do I get the number of CPUs a computer has
> |  > without parsing any file. 
> |  > something like sysctl on BSD.(just in linux it's not there)
> |  
> |  /proc/cpuinfo

Oh sorry, I skipped the "parsing" line. 

Anyhow... I reckon Linus has expressed before his dislike for special
system calls to get kernel information, and wants people to use proc
only. So unless I'm missing something I guess you're out of luck.

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).


=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il