home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / convex / 39 < prev    next >
Encoding:
Text File  |  1993-01-22  |  1.9 KB  |  60 lines

  1. Newsgroups: comp.sys.convex
  2. Path: sparky!uunet!cs.utexas.edu!convex!rosenkra
  3. From: rosenkra@convex.com (William Rosenkranz)
  4. Subject: Re: is there a system call to return the number of processor?
  5. Message-ID: <1993Jan22.061023.12840@convex.com>
  6. Sender: usenet@convex.com (news access account)
  7. Nntp-Posting-Host: convex1.convex.com
  8. Organization: CONVEX Computer Corporation, Richardson, Tx., USA
  9. References: <1993Jan19.132612.4970@wl.com>
  10. Distribution: usa
  11. Date: Fri, 22 Jan 1993 06:10:23 GMT
  12. X-Disclaimer: This message was written by a user at CONVEX Computer
  13.               Corp. The opinions expressed are those of the user and
  14.               not necessarily those of CONVEX.
  15. Lines: 43
  16.  
  17. In article <1993Jan19.132612.4970@wl.com> agrafiot@wl.com (Dimitris Agrafiotis) writes:
  18. >Is there a system call that returns the number of processors available
  19. >on a convex?
  20. >Thanks
  21.  
  22. getsysinfo(2) does report the number of CPUs in the box. however, if you
  23. have set "limit concurrency n" from the shell to a lesser number, you can
  24. also do a limit command from within a program to find out the number of
  25. processes actually used (note that i don't know the behavior if your
  26. launching shell is sh or ksh, i just know this works if it is csh):
  27.  
  28. #include <stdio.h>
  29. char buf[1025];
  30. void main (int argc, char *argv[])
  31. {
  32.     FILE *stream;
  33.  
  34.     if ((stream = popen("csh -c limit", "r")) == (FILE *) NULL)
  35.     {
  36.         fprintf (stderr, "popen failed\n");
  37.         exit (1);
  38.     }
  39.     while (1)
  40.     {
  41.         fgets (buf, 1024, stream);
  42.         if (feof (stream))
  43.             break;
  44.         fputs (buf, stdout);
  45.     }
  46.     exit (0);
  47. }
  48.  
  49. say u have a 4 processor system and did "limit concurrency 2" from csh.
  50. this should report 2 for concurrency (which you'll have to parse from
  51. the popen stream, ie look for "concurrency"). getsysinfo(2) would report
  52. 4 CPUs...
  53.  
  54. -bill
  55. rosenkra@convex.com
  56.  
  57. -- 
  58. Bill Rosenkranz            |UUCP: {uunet,texsun}!convex!rosenkra
  59. Convex Computer Corp.      |ARPA: rosenkra@convex.com
  60.