Path: galaxy.trc.rwcp.or.jp!jaist-news!cs.titech!nirvana.cs.titech!wnoc-tyo-news!scslwide!wsgw!headgw!cepgw!bigbird!sanewo
From: sanewo@cep.sony.co.jp (SANETO Takanori)
Newsgroups: fj.sys.sun
Subject: Re: top for sunos5mp
Message-ID: <SANEWO.94Jan10160603@sanewo.cep.sony.co.jp>
Date: 10 Jan 94 07:06:03 GMT
References: <945@astslc.a-s-tech.snet.or.jp>
Sender: Usenet News System <news@cep.sony.co.jp>
Organization: Sony Computer Entertainment, JAPAN
Lines: 98
Nntp-Posting-Host: sanewo
Dnas-Posting-Host: sanewo.cep.sony.co.jp
Xref: galaxy.trc.rwcp.or.jp fj.sys.sun:5360
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.sys.sun&nb=5360&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

In article <945@astslc.a-s-tech.snet.or.jp>,
lckam@astslc.a-s-tech.snet.or.jp (ast-1) writes:
> $B2q<R$N%^%7%s(B(SS10/41)$B$K(BmbusCPU$B%b%8%e!<%k$r(B
> $BDI2C$7$F%^%k%A%W%m%;%C%59=@.(B(SS10/412 ?)$B$K$7$?$H$3$m(B
> top$B$,F0$+$J$/$J$C$F$7$^$$$^$7$?!#(B

top-3.3beta $B$r1Q8lHG$N(B Solaris 2.2 $B$G$A$c$s$HF0$/$h$&$K$7$?$b$N$r(B
$B;H$C$F$$$^$9!#(B

> $BEvJ}$G!"Lu$b$o$+$i$:!"F0$+$J$$ItJ,$K0J2<$N(Bpatch$B$r(B
> $BEv$F$?$H$3$m2?$H$J$/F0$-$@$7$^$7$?$,!"(B

$BLdBj$O!"(Bmachine/m_sunos5.c $B$NCf$G!"M-8z$J(B cpu $B$NH=Dj$N;EJ}$r4V0c$C(B
$B$F$$$k$3$H$K$"$k$h$&$G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18 16:22:56 1993
@@ -88,7 +88,7 @@
 #define X_MAXMEM 7
 #define X_AVAILRMEM 8
 #define X_SWAPFS_MINFREE 9
-#define X_NCPUS   10
+#define X_CPU_AVAILABLE10
 
 static struct nlist nlst[] =
 {
@@ -102,7 +102,7 @@
   {"maxmem"},/* 7 */
   {"availrmem"},/* 8 */
   {"swapfs_minfree"},/* 9 */
-  {"ncpus"},/* 10 */
+  {"cpu_available"},/* 10 */
   {0}
 };
 
@@ -183,6 +183,7 @@
 static DIR *procdir;
 static int nproc;
 static int ncpus;
+static unsigned int cpu_available;
 
 /* these are for keeping track of the proc array */
 static int bytes;
@@ -240,11 +241,25 @@
     availrmem_offset = nlst[X_AVAILRMEM].n_value;
     swapfs_minfree_offset = nlst[X_SWAPFS_MINFREE].n_value;
 
-    (void) getkval (nlst[X_NCPUS].n_value, (int *) (&ncpus),
-    sizeof (ncpus), "ncpus");
-    cpu_offset = (unsigned long *) malloc (ncpus * sizeof (unsigned long));
-    (void) getkval (nlst[X_CPU].n_value, cpu_offset,
-    ncpus * sizeof (unsigned long), nlst[X_CPU].n_name);
+    {
+int max;
+unsigned int avl;
+int i, j;
+
+(void) getkval (nlst[X_CPU_AVAILABLE].n_value, (int *) (&cpu_available),
+sizeof (cpu_available), nlst[X_CPU_AVAILABLE].n_name);
+for (avl = cpu_available; avl; max++, avl >>=1) ;
+cpu_offset = (unsigned long *) malloc (max * sizeof (unsigned long));
+(void) getkval (nlst[X_CPU].n_value, cpu_offset,
+max * sizeof (unsigned long), nlst[X_CPU].n_name);
+for (i=0, j=0, avl = cpu_available; i < max; i++, avl>>=1) {
+    if (avl & 1) {
+cpu_offset[j] = cpu_offset[i];
+j++;
+    }
+}
+ncpus = j;
+    }
 
     /* allocate space for proc structure array and array of pointers */
     bytes = nproc * PRPSINFOSIZE;
---
$B$5$M$r(B@$B%=%K!<(B
sanewo@cep.sony.co.jp
