From: fazlin on
Hello All,

Is there any kernel APIs or variable to find out the number of CPUs in
a system. From user space, i can use /proc/cpuinfo file but is there a
way to do it from kernel.

Thanks in advance,
Fazlin
From: Whiskers on
On 2008-11-13, fazlin <fazlincse(a)gmail.com> wrote:
> Hello All,
>
> Is there any kernel APIs or variable to find out the number of CPUs in
> a system. From user space, i can use /proc/cpuinfo file but is there a
> way to do it from kernel.
>
> Thanks in advance,
> Fazlin

If you mean 'is there a console command', try

uname -p

On my computer, I have a P4 HT, which uname identifies as one CPU - but
/proc/cpuinfo is fooled by the two 'threads' supported by that chip into
listing two CPUs. I've never used a system with two or more CPUs
available, so I can't comment on what uname reports in such cases.

You can extract the list of CPUs contained in /proc/cpuinfo using

grep "model name" /proc/cpuinfo

or just get a count using

grep "model name" /proc/cpuinfo |wc -l

See the man pages for uname, grep, and wc for more about what those
commands do.

--
-- ^^^^^^^^^^
-- Whiskers
-- ~~~~~~~~~~
From: Martin Gregorie on
On Thu, 13 Nov 2008 12:47:51 +0000, Whiskers wrote:

> If you mean 'is there a console command', try
>
> uname -p
>
> On my computer, I have a P4 HT, which uname identifies as one CPU - but
> /proc/cpuinfo is fooled by the two 'threads' supported by that chip into
> listing two CPUs. I've never used a system with two or more CPUs
> available, so I can't comment on what uname reports in such cases.
>
On my systems (one P3 Coppermine and a laptop with a Core Duo T2330)
"uname -p" simply says 'i686' on both machines.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
From: Big and Blue on
fazlin wrote:
> Hello All,
>
> Is there any kernel APIs or variable to find out the number of CPUs in
> a system. From user space, i can use /proc/cpuinfo file but is there a
> way to do it from kernel.


"From the kernel". Are you writing a kernel module? If not then
/proc/cpuinfo *is* the kernel interface.

--
Just because I've written it doesn't mean that
either you or I have to believe it.
From: Johnny B Good on
The message <gfi34c$sb0$6(a)localhost.localdomain>
from Martin Gregorie <martin(a)see.sig.for.address.invalid> contains these
words:

> On Thu, 13 Nov 2008 12:47:51 +0000, Whiskers wrote:

> > If you mean 'is there a console command', try
> >
> > uname -p
> >
> > On my computer, I have a P4 HT, which uname identifies as one CPU - but
> > /proc/cpuinfo is fooled by the two 'threads' supported by that chip into
> > listing two CPUs. I've never used a system with two or more CPUs
> > available, so I can't comment on what uname reports in such cases.
> >
> On my systems (one P3 Coppermine and a laptop with a Core Duo T2330)
> "uname -p" simply says 'i686' on both machines.

That's awfully close to i666[1]. Just as well the subject title
_wasn't_ Number Of The CPU. ;-)

[1] I know, _The_Number_ wasn't actually 666, but I've forgotten the
actual number now (for all I know, it might even have been 686 ;-)

--
Regards, John.

Please remove the "ohggcyht" before replying.
The address has been munged to reject Spam-bots.

 |  Next  |  Last
Pages: 1 2
Prev: Distro suggestion
Next: In praise of Windows