Subject: PATCH: SOLUTION: Top on a two processor sparc10

From: [email-masked] (Jason C. Austin)
Date: 02 Mar 1994 17:49:27 GMT

Several people asked for my patch to the m_sunos5.c file to
get it working on a 2 processor Sparc 10 (It already works on a 4
processor).

	This is an unofficial patch to top-3.2.  It is provided "as
is" without express or implied warranty.

	Change directory to the "machine" directory in the top source
and feed this file to patch.

-- Cut Here --
*** 1.1	1994/03/01 18:52:30
--- m_sunos5.c	1994/03/01 19:14:49
***************
*** 57,60 ****
--- 57,61 ----
  #define KMEM "/dev/kmem"
  #define PROCFS "/proc"
+ #define MAXCPUS       4
  #define CPUSTATES     5
  #ifndef PRIO_MIN
***************
*** 208,211 ****
--- 209,214 ----
      static struct var v;
      struct oldproc *op, *endbase;
+     int i,j;
+     unsigned long tmp_cpu_offset[MAXCPUS];
  
      /* fill in the statics information */
***************
*** 244,249 ****
  		    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);
  
      /* allocate space for proc structure array and array of pointers */
--- 247,259 ----
  		    sizeof (ncpus), "ncpus");
      cpu_offset = (unsigned long *) malloc (ncpus * sizeof (unsigned long));
!     (void) getkval (nlst[X_CPU].n_value, tmp_cpu_offset,
! 		    MAXCPUS * sizeof (unsigned long), nlst[X_CPU].n_name);
!     j=0;
!     for(i=0;i<MAXCPUS;i++)
!       if (tmp_cpu_offset[i]!=0) {
! 	cpu_offset[j++]=tmp_cpu_offset[i];
! 	if (j>=ncpus)
! 	  break;
!       }
  
      /* allocate space for proc structure array and array of pointers */