ftp.nice.ch/peanuts/GeneralData/Usenet/news/1989/CSN-89.tar.gz#/comp-sys-next/1989/May-Jun/nlist-initialization?

This is nlist-initialization? in view mode; [Up]


Date: Sun 05-Jun-1989 23:55:22 From: Unknown Subject: nlist initialization? Can anyone tell me how to do what I am obviously attempting to do below on the next? These few lines are from sendmail 5.61. I presume that the Mach nlist format is preventing this from working. The error I get (twice) is "type mismatch in initialization," with a line number pointing to the closing brace of the initialization. I tried it with the -bsd flag and it doesn't change. #include <nlist.h> struct nlist Nl[] = { { "_avenrun" }, #define X_AVENRUN 0 { 0 }, }; Steve Hubert Networks and Distributed Computing, Univ. of Wash. hubert@cac.washington.edu >From: johnsot@mist.CS.ORST.EDU (Tim G. Johnson)
Date: Sun 06-Jun-1989 04:22:59 From: Unknown Subject: Re: nlist initialization? In article <1499@uw-entropy.ms.washington.edu> hubert@cac.washington.edu (Steve Hubert) writes: > >I presume that the Mach nlist format is preventing this from working. >The error I get (twice) is "type mismatch in initialization," with a line >number pointing to the closing brace of the initialization. I tried it >with the -bsd flag and it doesn't change. Since the name in the nlist specification in nlist.h now resides within a union within the struct, you need to add an extra set of brackets around the name declarations: struct nlist Nl[] = { { { "_avenrun" } }, #define X_AVENRUN 0 { { "" } } } I used this declaration to try to get the load average on the NeXT. I was able to nlist into /vmunix (/mach) to get the proper offset in Nl.value, but when I did a lseek into /dev/kmem, I never got the load average. If you figure actually get a valid reading, let me know. Thanks. (BTW, try looking up _mach_factor too. I dunno what it is really, though. /usr/ucb/w will show the mach factor with the -m flag.) Tim G. Johnson Computer Science Dept. johnsot@CS.ORST.EDU 308 Weatherford Hall Oregon State University hplabs!hp-pcd!orstcs!johnsot Corvallis, OR 97331 Corvallis, OR 97331 tektronix!orstcs!johnsot (503) 758-9639 (503) 754-3273 johnsot@oregon-state.BITNET >From: avie@wb1.cs.cmu.edu (Avadis Tevanian)
Date: Sun 06-Jun-1989 08:12:52 From: Unknown Subject: Re: nlist initialization? In article <10985@orstcs.CS.ORST.EDU> johnsot@mist.CS.ORST.EDU (Tim G. Johnson) writes: >but when I did a lseek into /dev/kmem, I never got the load average. >If you figure actually get a valid reading, let me know. Thanks. >(BTW, try looking up _mach_factor too. I dunno what it is really, though. >/usr/ucb/w will show the mach factor with the -m flag.) > Mach doesn't use any floating point internally, so it stores the load average as a scaled integer, with a scale factor of 1000 (LSCALE in sys/kernel.h). The Mach Factor is an interesting number I made up a couple of years ago. It is intended to take into account multiprocessors, and is a measure of the expected number of processors that would be available to your application if you were to run it. For example, if there was one compute bound thread in a single cpu system, the Mach Factor would be .5 (expect 1/2 of 1 cpu). If you had 1 thread running on 2 processor system, you could expect to get 1 whole cpu, thus a Mach Factor of 1, if there were 2 threads on that same system, you could expect to get 2/3rd of a cpu (3 threads would share 2 processors if you launched a new thread), hence a Mach Factor of 0.6666.
Date: Sun 06-Jun-1989 15:45:35 From: Unknown Subject: Re: nlist initialization? I run a version of rwhod on 0.9 that reads and prints the load average correctly. Diffs from the the 4.3 rwhod follow. The load average scaling should probably be done from "LSCALE" directly, but if memory serves, I ran into some problems in sys/kernel.h that made this way much easier. They probably aren't insurmountable, but just not worth it to me when I was doing it... *** 4.3BSD rwhod.c Tue Jun 6 10:39:57 1989 --- /usr/src/etc/rwhod.c Thu May 18 13:39:09 1989 *************** *** 51,60 **** struct nlist nl[] = { #define NL_AVENRUN 0 ! { "_avenrun" }, #define NL_BOOTTIME 1 ! { "_boottime" }, ! 0 }; /* --- 51,60 ---- struct nlist nl[] = { #define NL_AVENRUN 0 ! { { "_avenrun" } }, #define NL_BOOTTIME 1 ! { { "_boottime" } }, ! { {0} } }; /* *************** *** 80,86 **** #define RWHODIR "/usr/spool/rwho" int onalrm(); ! char *strcpy(), *sprintf(), *malloc(); char *whittle(); long lseek(); int getkmem(); --- 80,89 ---- #define RWHODIR "/usr/spool/rwho" int onalrm(); ! char *strcpy(), *malloc(); ! #ifndef NeXT ! char *sprintf(); ! #endif /* not NeXT */ char *whittle(); long lseek(); int getkmem(); *************** *** 255,265 **** struct stat stb; register struct whoent *we = mywd.wd_we, *wlast; int cc; ! #ifdef sun long avenrun[3]; ! #else NOT sun double avenrun[3]; ! #endif sun time_t now = time(0); register struct neighbor *np; --- 258,268 ---- struct stat stb; register struct whoent *we = mywd.wd_we, *wlast; int cc; ! #if defined(sun) || defined(NeXT) long avenrun[3]; ! #else /* NOT (sun || NeXT) */ double avenrun[3]; ! #endif /* sun || NeXT */ time_t now = time(0); register struct neighbor *np; *************** *** 321,331 **** (void) lseek(kmemf, (long)nl[NL_AVENRUN].n_value, L_SET); (void) read(kmemf, (char *)avenrun, sizeof (avenrun)); for (i = 0; i < 3; i++) ! #ifdef sun mywd.wd_loadav[i] = htonl((u_long)(((double)avenrun[i]/FSCALE) * 100.)); ! #else NOT sun mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100)); ! #endif sun cc = (char *)we - (char *)&mywd; mywd.wd_sendtime = htonl(time(0)); mywd.wd_vers = WHODVERSION; --- 324,339 ---- (void) lseek(kmemf, (long)nl[NL_AVENRUN].n_value, L_SET); (void) read(kmemf, (char *)avenrun, sizeof (avenrun)); for (i = 0; i < 3; i++) ! #if defined(sun) mywd.wd_loadav[i] = htonl((u_long)(((double)avenrun[i]/FSCALE) * 100.)); ! #endif /* sun */ ! #if defined(NeXT) ! /* LSCALE must match sys/kernel.h!!! */ ! /* divide by (LSCALE/100) (from sys/kernel.h, LSCALE == 1000) */ ! mywd.wd_loadav[i] = htonl((avenrun[i]+5)/10); ! #else mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100)); ! #endif cc = (char *)we - (char *)&mywd; mywd.wd_sendtime = htonl(time(0)); mywd.wd_vers = WHODVERSION;

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.