lkml.org 
[lkml]   [2008]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] sched: Improve readability in update_cpu_load() code
    On Thu, May 15, 2008 at 08:22:15PM +0530, Srivatsa Vaddagiri wrote:
    > This wont work when new_load < old_load ..
    >
    > For ex: I tried this prog:
    >
    > #include <stdio.h>
    >
    > main()
    > {
    > unsigned long old_load = 100, new_load = 90, this_load, this_load1;
    > int i = 1, scale = 2 << i;

    s/scale = 2<< i/scale = 2 << (i-1)

    >
    > this_load = (old_load*(scale-1) + new_load) >> i;
    > this_load1 = old_load + ((new_load - old_load) >> i);
    >
    > printf ("this_load = %u, this_load1 = %u \n", this_load, this_load1);
    > }
    >
    > This is what I get:
    >
    > $ ./a.out
    > this_load = 195, this_load1 = 2147483743
    > $

    [with above modification:]

    this_load = 95, this_load1 = 2147483743


    --
    Regards,
    vatsa


    \
     
     \ /
      Last update: 2008-05-15 16:57    [W:0.020 / U:2.804 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site