Index: machine.c =================================================================== RCS file: /home/ncvs/src/usr.bin/top/machine.c,v retrieving revision 1.77 diff -u -r1.77 machine.c --- machine.c 11 Jun 2006 19:18:39 -0000 1.77 +++ machine.c 26 Aug 2006 08:41:29 -0000 @@ -58,6 +58,8 @@ extern struct process_select ps; extern char* printable(char *); static int smpmode; +static int ncpu; +#define NCPU 2 /* support max 2cpu to display frequency */ enum displaymodes displaymode; static int namelength = 8; static int cmdlengthdelta; @@ -147,10 +149,10 @@ /* these are for detailing the process states */ -int process_states[8]; +int process_states[8+NCPU]; char *procstatenames[] = { "", " starting, ", " running, ", " sleeping, ", " stopped, ", - " zombie, ", " waiting, ", " lock, ", + " zombie, ", " waiting, ", " lock, ", " MHz, ", " MHz, ", NULL }; @@ -234,6 +236,13 @@ modelen != sizeof(smpmode)) smpmode = 0; + for (ncpu = -1; ncpu < NCPU; ncpu++) { + char buf[32]; + snprintf(buf, sizeof buf-1, "dev.cpu.%d.freq", ncpu+1); + if (sysctlbyname(buf, NULL, NULL, NULL, 0) < 0) + break; + } + while ((pw = getpwent()) != NULL) { if (strlen(pw->pw_name) > namelength) namelength = strlen(pw->pw_name); @@ -632,6 +641,16 @@ } } + /* CPU current frequency */ + if (ncpu != -1) { + int j; + for(j = 0; j <= ncpu; j++) { + char buf[32]; + snprintf(buf, sizeof buf-1, "dev.cpu.%d.freq", j); + GETSYSCTL(buf, process_states[j+8]); + } + } + /* if requested, sort the "interesting" processes */ if (compare != NULL) qsort(pref, active_procs, sizeof(*pref), compare);