1 --- procps-3.2.7/top.c.kzak 2006-08-31 10:44:42.000000000 +0200
2 +++ procps-3.2.7/top.c 2006-08-31 10:46:15.000000000 +0200
4 Secure_mode = 0; // set if some functionality restricted
6 static int VIRT_vmsize = 0; //use vm_size for VIRT
7 +static int CPU_loop = 0; // wait for reliable CPU data
9 /* Some cap's stuff to reduce runtime calls --
10 to accomodate 'Batch' mode, they begin life as empty strings */
13 if (( getenv("STATSIZE")) && ( atoi(getenv("STATSIZE")) == 1 ))
15 + if (( getenv("CPULOOP")) && ( atoi(getenv("CPULOOP")) == 1 ))
22 static proc_t **p_table = NULL;
23 static CPU_t *smpcpu = NULL;
24 + static int first = 0;
26 // whoa first time, gotta' prime the pump...
28 @@ -3025,6 +3029,28 @@
30 smpcpu = cpus_refresh(smpcpu);
32 + if (first==0 && CPU_loop)
36 + for (i = 0; i < Cpu_tot; i++) {
38 + cpu->u_sav = cpu->u;
39 + cpu->s_sav = cpu->s;
40 + cpu->n_sav = cpu->n;
41 + cpu->i_sav = cpu->i;
42 + cpu->w_sav = cpu->w;
43 + cpu->x_sav = cpu->x;
44 + cpu->y_sav = cpu->y;
45 + cpu->z_sav = cpu->z;
47 + tv.tv_sec = Rc.delay_time;
48 + tv.tv_usec = (Rc.delay_time - (int)Rc.delay_time) * 1000000;
49 + select(0, NULL, NULL, NULL, &tv);
51 + smpcpu = cpus_refresh(smpcpu);
54 if (CHKw(Curwin, View_CPUSUM)) {
55 // display just the 1st /proc/stat line
56 summaryhlp(&smpcpu[Cpu_tot], "Cpu(s):");
60 SETw(Curwin, NEWFRAM_cwo);
66 --- procps-3.2.7/top.1.kzak 2006-08-31 10:44:42.000000000 +0200
67 +++ procps-3.2.7/top.1 2006-08-31 10:44:42.000000000 +0200
68 @@ -1183,6 +1183,13 @@
70 Albert D\. Cahalan, <albert@users.sf.net>
72 +The top command calculates Cpu(s) by looking at the change in CPU time values
73 +between samples. When you first run it, it has no previous sample to compare
74 +to, so these initial values are the percentages since boot. It means you need
75 +at least two loops or you have to ignore summary output from the first loop.
76 +This is problem for example for batch mode. There is a possible workaround if
77 +you define the CPULOOP=1 environment variable. The top command will be run one
78 +extra hidden loop for CPU data before standard output.
80 .\" ----------------------------------------------------------------------
81 .SH 8. HISTORY Former top