This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: how to get the number of CPUs?
- From: Cong <vo dot chi dot cong at is dot titech dot ac dot jp>
- To: me at rupey dot net
- Cc: bharathi at lantana dot tenet dot res dot in, gcc-help at gcc dot gnu dot org
- Date: Sun, 07 Jul 2002 13:24:10 +0900 (JST)
- Subject: Re: how to get the number of CPUs?
- References: <616BE6A276E3714788D2AC35C40CD18D5EC4E6@whale.softwire.co.uk>
Thank you, your code works for me!
But, when I do man sysconf on Linux, it show no infomation
about _SC_NPROCESSORS_CONF as manpage on Solaris do. However, looking
at <unistd.h>, they're there!
Cong
> > On Thu, 4 Jul 2002, Cong wrote:
> > > number of CPUs on each of them. So I want to get the number of CPUs
> > cpu info is avilable in /proc/cpuinfo file
> > if processor is 0 then No. of CPU is 1
> > Explore /proc dir you will more idea :)
>
> Or the sysconf solution - for Solaris, at least, but this ought to be
> portable:
>
> #include <stdio.h>
> #include <unistd.h>
>
> int main(void)
> {
> long nProcessorsConfigured = sysconf(_SC_NPROCESSORS_CONF);
> long nProcessorsOnline = sysconf(_SC_NPROCESSORS_ONLN);
>
> Try 'man sysconf' to get a list of supported sysconf arguments and their
> descriptions on your platform.
>