This is the mail archive of the ecos-discuss@sourceware.cygnus.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: nc_test_slave.c fix



On 06-Apr-00 Grant Edwards wrote:
> 
> In the calibrate_load() function in nc_test_slave.c, the while(1)
> loop will never terminate if percent_load >= desired_load && delta == 1.
> 
> The code at the end of the loop needs to be changed from 
> 
>             load_thread_level -= (delta / 2);
> to        
>             load_thread_level -= (delta / 2) ? (delta / 2) : 1;
> 

Yes, I've already encountered this (has a lot to do with testing on
machines of vastly different speeds).  Here's how I changed it:

        if (abs(desired_load-percent_load) <= 2) break;
        delta = load_thread_level - prev_load_level;
        prev_load_level = load_thread_level;
        if (percent_load < desired_load) {
            load_thread_level *= 2;
        } else {            
            if (delta < 0) {
                // Trying to decrease load, but haven't gone far enough yet
                if (abs(delta) < 2) delta = -2;
                delta = abs(delta);
            }
            load_thread_level -= delta / 2;
        }


Does this work for you as well?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]