Updated with Tizen:Base source codes
[external/procps.git] / packaging / procps-3.2.6-top-env-cpuloop.patch
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
3 @@ -121,6 +121,7 @@
4             Secure_mode = 0;     // set if some functionality restricted
5  
6  static int VIRT_vmsize = 0;    //use vm_size for VIRT 
7 +static int CPU_loop = 0;       // wait for reliable CPU data
8  
9          /* Some cap's stuff to reduce runtime calls --
10             to accomodate 'Batch' mode, they begin life as empty strings */
11 @@ -1679,6 +1680,8 @@
12     
13     if (( getenv("STATSIZE")) && ( atoi(getenv("STATSIZE")) == 1 )) 
14            VIRT_vmsize = 1;
15 +   if (( getenv("CPULOOP")) && ( atoi(getenv("CPULOOP")) == 1 )) 
16 +          CPU_loop = 1;
17  }
18  
19  
20 @@ -2978,6 +2981,7 @@
21  {
22     static proc_t **p_table = NULL;
23     static CPU_t  *smpcpu = NULL;
24 +   static int first = 0;
25  
26     // whoa first time, gotta' prime the pump...
27     if (!p_table) {
28 @@ -3025,6 +3029,28 @@
29  
30        smpcpu = cpus_refresh(smpcpu);
31  
32 +      if (first==0 && CPU_loop)
33 +      {
34 +        int i;
35 +        CPU_t *cpu;
36 +        for (i = 0; i < Cpu_tot; i++) {
37 +           cpu =  &smpcpu[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;
46 +        }
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);
50 +
51 +        smpcpu = cpus_refresh(smpcpu);
52 +      }
53 +
54        if (CHKw(Curwin, View_CPUSUM)) {
55           // display just the 1st /proc/stat line
56           summaryhlp(&smpcpu[Cpu_tot], "Cpu(s):");
57 @@ -3050,6 +3076,8 @@
58     }
59  
60     SETw(Curwin, NEWFRAM_cwo);
61 +
62 +   first = 1;
63     return p_table;
64  }
65  
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 @@
69  Send bug reports to:
70     Albert D\. Cahalan, <albert@users.sf.net>
71  
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.
79  
80  .\" ----------------------------------------------------------------------
81  .SH 8. HISTORY Former top