This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
RE: nc_test_slave.c fix
- To: Grant Edwards <grante at visi dot com>
- Subject: RE: [ECOS] nc_test_slave.c fix
- From: Gary Thomas <gthomas at redhat dot com>
- Date: Thu, 06 Apr 2000 17:48:53 -0600 (MDT)
- Cc: ecos-discuss at sourceware dot cygnus dot com
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?