[parent not found: <616BE6A276E3714788D2AC35C40CD18D6C01F7@whale.softwire.co.uk>]
* RE: how to get the number of CPUs?
[not found] <616BE6A276E3714788D2AC35C40CD18D6C01F7@whale.softwire.co.uk>
@ 2002-07-04 5:52 ` Rupert Wood
2002-07-06 21:24 ` Cong
0 siblings, 1 reply; 6+ messages in thread
From: Rupert Wood @ 2002-07-04 5:52 UTC (permalink / raw)
To: 'Cong'; +Cc: 'Bharathi S', gcc-help
Bharathi S. wrote:
> 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);
if (nProcessorsConfigured != -1)
{
printf("Processors configured :
%ld\n",nProcessorsConfigured);
}
else
{
printf("Unable to read configured processor count.\n");
}
if (nProcessorsOnline != -1)
{
printf("Processors online : %ld\n",nProcessorsOnline);
}
else
{
printf("Unable to read online processor count.\n");
}
return 0;
}
Try 'man sysconf' to get a list of supported sysconf arguments and their
descriptions on your platform.
Rup.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to get the number of CPUs?
2002-07-04 5:52 ` Rupert Wood
@ 2002-07-06 21:24 ` Cong
2002-07-13 8:00 ` Nix
0 siblings, 1 reply; 6+ messages in thread
From: Cong @ 2002-07-06 21:24 UTC (permalink / raw)
To: me; +Cc: bharathi, gcc-help
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.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to get the number of CPUs?
2002-07-06 21:24 ` Cong
@ 2002-07-13 8:00 ` Nix
0 siblings, 0 replies; 6+ messages in thread
From: Nix @ 2002-07-13 8:00 UTC (permalink / raw)
To: Cong; +Cc: gcc-help
On Sun, 7 Jul 2002, Cong yowled:
> 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!
The manpage is not the canonical information source for the GNU C
library.
Try `info libc processor resources', or
`info libc --index-search=_SC_NPROCESSORS_CONF'.
--
`There's something satisfying about killing JWZ over and over again.'
-- 1i, personal communication
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: how to get the number of CPUs?
@ 2002-07-04 13:11 Dockeen
0 siblings, 0 replies; 6+ messages in thread
From: Dockeen @ 2002-07-04 13:11 UTC (permalink / raw)
To: gcc-help
In case anyone cares, the specified code works on a Win98 PC
running Cygwin...
Coolies!!!!!!!
Thanks,
Wayne Keen
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-07-13 15:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1025766825.11142.ezmlm@gcc.gnu.org>
2002-07-04 4:45 ` how to get the number of CPUs? Cong
2002-07-04 5:30 ` Bharathi S
[not found] <616BE6A276E3714788D2AC35C40CD18D6C01F7@whale.softwire.co.uk>
2002-07-04 5:52 ` Rupert Wood
2002-07-06 21:24 ` Cong
2002-07-13 8:00 ` Nix
2002-07-04 13:11 Dockeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).