|
Home > Archive > Unix Programming > August 2005 > Determine number of CPUs
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Determine number of CPUs
|
|
| Gianni Mariani 2005-08-16, 5:59 pm |
|
Is there any portable way to determine the number of CPUs running ? Or
perhaps if the machine is SMP or not.
On Linux, the only thing I can think of is reading /proc/cpuinfo !
G
| |
| Rich Teer 2005-08-16, 5:59 pm |
| On Tue, 16 Aug 2005, Gianni Mariani wrote:
> Is there any portable way to determine the number of CPUs running ? Or
> perhaps if the machine is SMP or not.
Which version of UNIX? With Solaris you can use sysconf (_SC_NPROCESSORS_ONLN)
for the number of online processors and sysconf (_SC_NPROCESSORS_CONF) to see
how many CPUs are installed.
--
Rich Teer, SCNA, SCSA, OpenSolaris CAB member
President,
Rite Online Inc.
Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
| |
| Maxim Yegorushkin 2005-08-17, 3:06 am |
| Gianni Mariani wrote:
> Is there any portable way to determine the number of CPUs running ? Or
> perhaps if the machine is SMP or not.
>
> On Linux, the only thing I can think of is reading /proc/cpuinfo !
<bits/confname.h> from FC4:
/* Values according to POSIX 1003.1c (POSIX threads). */
#define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CO
NF
#define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ON
LN
| |
| Gianni Mariani 2005-08-17, 7:54 am |
| Rich Teer wrote:
> On Tue, 16 Aug 2005, Gianni Mariani wrote:
>
>
>
>
> Which version of UNIX? With Solaris you can use sysconf (_SC_NPROCESSORS_ONLN)
> for the number of online processors and sysconf (_SC_NPROCESSORS_CONF) to see
> how many CPUs are installed.
>
Perfect !
Thanks to all that replied.
|
|
|
|
|