Re: Get number of CPU?

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

 



you could use /proc/cpuinfo.
just 'cat' that and parse to get what you want.
- Ratnadeep

On 6/28/05, NAHieu <nahieu@xxxxxxxxx> wrote:
> On 6/27/05, Jan Hudec <bulb@xxxxxx> wrote:
> > On Mon, Jun 27, 2005 at 10:59:39 +0900, NAHieu wrote:
> > > On 6/27/05, Tetsuo Handa <from-kernelnewbies@xxxxxxxxxxxxxxxxxxx> wrote:
> > > > > > I am writing a kernel module, and I want to get the number of CPU. If
> > > > > > the machine is UP, the value returned will be 1, but if the machine is
> > > > > > SMP, the value returned will be the number of CPU available.
> > > > >
> > > > > I think NR_CPUS give the number of the cpu in the system. You can use it
> > > >
> > > > NR_CPUS is the max number that kernel supports.
> > > > I think num_online_cpus() is what you want.
> > > > http://lxr.linux.no/source/include/linux/cpumask.h#L349
> > >
> > > Looks like num_online_cpus() is not exported, so it is impossible to
> > > use it from a module, isnt it?
> >
> > Did you even bother to look at the link above ?!?!
> >
> > If you did, you'd know that it is a preprocessor macro, so it does not
> > have a symbol that'd need exporting. Also you'd learn that it actually
> > uses a function underneath, which is exported.
> 
> Jan, i see that.
> 
> Another question: if I want to get the number of CPU from userspace,
> it is possible to find it in /proc/cpu. Is there any other way (using
> library, syscall,...) to do that?
> 
> Thank you,
> Hieu
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux