On Sun, 20 Aug 2006 17:24:35 +0900 Norikatsu Shigemura <[EMAIL PROTECTED]> wrote: > 1. assume only 1 CPU. > 2. assume dev.cpu.0.freq is always exists. > 3. display position is good?
I modified 1 and 2. Please check attached diff. I couldn't fix 3 issue. So I assumed support max 2CPUs. I confirmed following environments. - - PentiumIII-S dual - - - - - - - - - - - - - dev.cpu.0.%desc: ACPI CPU dev.cpu.0.%driver: cpu dev.cpu.0.%location: handle=\_PR_.CPU0 dev.cpu.0.%pnpinfo: _HID=none _UID=0 dev.cpu.0.%parent: acpi0 dev.cpu.1.%desc: ACPI CPU dev.cpu.1.%driver: cpu dev.cpu.1.%location: handle=\_PR_.CPU1 dev.cpu.1.%pnpinfo: _HID=none _UID=0 dev.cpu.1.%parent: acpi0 - - PentiumIII-S dual - - - - - - - - - - - - - - - Pentium-M Dothan - - - - - - - - - - - - - - dev.cpu.0.%desc: ACPI CPU dev.cpu.0.%driver: cpu dev.cpu.0.%location: handle=\_PR_.CPU0 dev.cpu.0.%pnpinfo: _HID=none _UID=0 dev.cpu.0.%parent: acpi0 dev.cpu.0.freq: 1200 dev.cpu.0.freq_levels: 1200/-1 1100/-1 1000/-1 900/-1 800/-1 700/-1 600/-1 525/-1 450/-1 375/-1 300/-1 225/-1 150/-1 75/-1 - - Pentium-M Dothan - - - - - - - - - - - - - - - - Xeon 2.8GHz - - - - - - - - - - - - - - - - dev.cpu.0.%desc: ACPI CPU dev.cpu.0.%driver: cpu dev.cpu.0.%location: handle=\_PR_.CPU0 dev.cpu.0.%pnpinfo: _HID=none _UID=0 dev.cpu.0.%parent: acpi0 dev.cpu.0.freq: 2807 dev.cpu.0.freq_levels: 2807/-1 2456/-1 2105/-1 1754/-1 1403/-1 1052/-1 701/-1 350/-1 - - Xeon 2.8GHz - - - - - - - - - - - - - - - -
Index: machine.c =================================================================== RCS file: /home/ncvs/src/usr.bin/top/machine.c,v retrieving revision 1.74 diff -u -r1.74 machine.c --- machine.c 18 May 2005 13:42:51 -0000 1.74 +++ machine.c 26 Aug 2006 08:41:50 -0000 @@ -61,6 +61,8 @@ extern char* printable(char *); int swapmode(int *retavail, int *retfree); 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; @@ -153,10 +155,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 }; @@ -235,6 +237,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); @@ -629,6 +638,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);
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);
_______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"