Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!bionet!agate!stanford.edu!CAMIS.STANFORD.EDU!lane From: lane@CAMIS.STANFORD.EDU (Christopher Lane) Newsgroups: comp.sys.next Subject: re: CPU load function? Message-ID: Date: 8 Apr 91 16:11:43 GMT References: <1991Apr8.063438.8964@engin.umich.edu> Sender: Christopher Lane Organization: Internet-USENET Gateway at Stanford University Lines: 40 > I'm looking for a C or Mach function that will get me the percent > usage/load of the CPU at any one time. If anyone knows of such a > beastie, please email me (or post it I guess). The function you probably want is 'table'. An example usage from LoadAve.c which is part of the NLoad application: /* 'table()' version of 'loadave()' suggested by Morris Meyer */ #import #import #define QUEUES 3 extern int table(); int loadave(long vector[QUEUES]) { struct tbl_loadavg tl; int i; if(table(TBL_LOADAVG, 0, &tl, 1, sizeof(tl)) == CERROR) return(CERROR); if(tl.tl_lscale == 0) return(CERROR); for (i = 0; i < QUEUES; i++) vector[i] = tl.tl_avenrun[i]; return(tl.tl_lscale); } >I need it (or something like it) to implement a NeXTstep version of a nifty >thing I've seen called xload on Suns here at Michigan.... Already been done, I'm afraid. It's called 'NLoad' and I promise to have a finished working version for 2.0 on the NeXT archives 'real soon now'. - Christopher -------