ps : Unknown HZ value! (91) Assume 100. 解决方案

 在2.6内核上执行ps, 出现如下错误:

Unknown HZ value! (91) Assume 100.

 PID TTY          TIME CMD
 XXX ttyS0    00:00:00 sh
 XXX ttyS0    00:00:00 ps
 
解决方法:
 
diff -Nur procps-3.2.8/proc/sysinfo.c procps-3.2.8-mod/proc/sysinfo.c
--- procps-3.2.8/proc/sysinfo.c 2012-02-05 14:43:07.000000000 +0800
+++ procps-3.2.8-mod/proc/sysinfo.c 2012-02-05 15:30:18.000000000 +0800
@@ -126,25 +126,26 @@
 unsigned long long Hertz;
 
 static void old_Hertz_hack(void){
-  unsigned long long user_j, nice_j, sys_j, other_j;  /* jiffies (clock ticks) */
+  unsigned long long user_j, nice_j, sys_j, other_j, wait_j, hirq_j, sirq_j, stol_j;
   double up_1, up_2, seconds;
   unsigned long long jiffies;
   unsigned h;
   char *savelocale;
 
+  wait_j = hirq_j = sirq_j = stol_j = 0;
   savelocale = strdup(setlocale(LC_NUMERIC, NULL));
   setlocale(LC_NUMERIC, "C");
   do{
     FILE_TO_BUF(UPTIME_FILE,uptime_fd);  sscanf(buf, "%lf", &up_1);
     /* uptime(&up_1, NULL); */
     FILE_TO_BUF(STAT_FILE,stat_fd);
-    sscanf(buf, "cpu %Lu %Lu %Lu %Lu", &user_j, &nice_j, &sys_j, &other_j);
+    sscanf(buf, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", &user_j, &nice_j, &sys_j, &other_j, &wait_j, &hirq_j, &sirq_j, &stol_j);
     FILE_TO_BUF(UPTIME_FILE,uptime_fd);  sscanf(buf, "%lf", &up_2);
     /* uptime(&up_2, NULL); */
   } while((long long)( (up_2-up_1)*1000.0/up_1 )); /* want under 0.1% error */
   setlocale(LC_NUMERIC, savelocale);
   free(savelocale);
-  jiffies = user_j + nice_j + sys_j + other_j;
+  jiffies = user_j + nice_j + sys_j + other_j + wait_j + hirq_j + sirq_j + stol_j ;
   seconds = (up_1 + up_2) / 2;
   h = (unsigned)( (double)jiffies/seconds/smp_num_cpus );
   /* actual values used by 2.4 kernels: 32 64 100 128 1000 1024 1200 */

 

你可能感兴趣的:(c,user,cmd,File,null,UP)