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

  1. Newsgroups: comp.sys.convex
  2. Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!sol.ctr.columbia.edu!eff!news.oc.com!convex!convex!schnoebe
  3. From: schnoebe@convex.com (Eric Schnoebelen)
  4. Subject: Re: is there a system call to return the number of processor?
  5. Originator: schnoebe@duke
  6. Sender: usenet@news.eng.convex.com (news access account)
  7. Message-ID: <1993Jan22.192314.10228@news.eng.convex.com>
  8. Date: Fri, 22 Jan 1993 19:23:14 GMT
  9. Distribution: usa
  10. References: <1993Jan22.061023.12840@convex.com>
  11. Nntp-Posting-Host: duke.convex.com
  12. Organization: C Series System Sofware, CONVEX Computer, Richardson, Tx. USA
  13. X-Disclaimer: This message was written by a user at CONVEX Computer
  14.               Corp. The opinions expressed are those of the user and
  15.               not necessarily those of CONVEX.
  16. Lines: 42
  17.  
  18. [Someone noted that I managed to mangle one of the rlimit structure
  19. field names, as well as the spelling of concurrency.  I've corrected
  20. both, and canceled the earlier article -- Eric ]
  21.  
  22. rosenkra@convex.com (William Rosenkranz) writes:
  23. - In article <1993Jan19.132612.4970@wl.com> agrafiot@wl.com (Dimitris Agrafiotis) writes:
  24. - >Is there a system call that returns the number of processors available
  25. - >on a convex?
  26. - >Thanks
  27. - getsysinfo(2) does report the number of CPUs in the box. however, if you
  28. - have set "limit concurrency n" from the shell to a lesser number, you can
  29. - also do a limit command from within a program to find out the number of
  30. - processes actually used (note that i don't know the behavior if your
  31. - launching shell is sh or ksh, i just know this works if it is csh):
  32.  
  33.     A much better way to get the resource limits in an application
  34. is to use getrlimit(2).  Starting up a Cshell is such a waste!
  35.  
  36.     A small sample routine to get the concurrency limit of the
  37. current process:
  38.  
  39. #include <sys/time.h>
  40. #include <sys/resource.h>
  41. #include <stdio.h>
  42.  
  43. int main()
  44. {
  45. struct rlimit info;
  46.     
  47.     if(getrlimit(RLIMIT_CONCUR, &info)) {
  48.         perror("rlimit");
  49.         return 1;
  50.     }
  51.  
  52.     printf("current concurrency: %d\n", info.rlim_cur);
  53.     printf("max concurrency: %d\n", info.rlim_max);
  54.     return 0;
  55. }
  56. -- 
  57. Eric Schnoebelen        eric@cirr.com        schnoebe@convex.com
  58. Life is the only game in which the object of the game is to learn the rules.
  59.