Article View: comp.sys.convex
Article #6Re: is there a system call to return the number of processor?
From: William Rosenkranz
Date: Fri, 22 Jan 1993 06:10
Date: Fri, 22 Jan 1993 06:10
43 lines
1979 bytes
1979 bytes
In article <1993Jan19.132612.4970@wl.com> agrafiot@wl.com (Dimitris Agrafiotis) writes:
>Is there a system call that returns the number of processors available
>on a convex?
>Thanks
getsysinfo(2) does report the number of CPUs in the box. however, if you
have set "limit concurrency n" from the shell to a lesser number, you can
also do a limit command from within a program to find out the number of
processes actually used (note that i don't know the behavior if your
launching shell is sh or ksh, i just know this works if it is csh):
#include <stdio.h>
char buf[1025];
void main (int argc, char *argv[])
{
FILE *stream;
if ((stream = popen("csh -c limit", "r")) == (FILE *) NULL)
{
fprintf (stderr, "popen failed\n");
exit (1);
}
while (1)
{
fgets (buf, 1024, stream);
if (feof (stream))
break;
fputs (buf, stdout);
}
exit (0);
}
say u have a 4 processor system and did "limit concurrency 2" from csh.
this should report 2 for concurrency (which you'll have to parse from
the popen stream, ie look for "concurrency"). getsysinfo(2) would report
4 CPUs...
-bill
rosenkra@convex.com
--
Bill Rosenkranz |UUCP: {uunet,texsun}!convex!rosenkra
Convex Computer Corp. |ARPA: rosenkra@convex.com
Technical Details
Message-ID:
<1993Jan22.061023.12840@convex.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!convex!rosenkraReferences:
<1993Jan19.132612.4970@wl.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.convex
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!convex!rosenkra
From: rosenkra@convex.com (William Rosenkranz)
Subject: Re: is there a system call to return the number of processor?
Message-ID: <1993Jan22.061023.12840@convex.com>
Sender: usenet@convex.com (news access account)
Nntp-Posting-Host: convex1.convex.com
Organization: CONVEX Computer Corporation, Richardson, Tx., USA
References: <1993Jan19.132612.4970@wl.com>
Distribution: usa
Date: Fri, 22 Jan 1993 06:10:23 GMT
X-Disclaimer: This message was written by a user at CONVEX Computer
Corp. The opinions expressed are those of the user and
not necessarily those of CONVEX.
Lines: 43