This is the mail archive of the ecos-patches@sourceware.org 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]
Other format: [Raw text]

RE: cpuload.cxx patch


> -  load = 100 - load;
> +  load = (100 - load)*100;

yes that's my improvement by multiplying the value with 100 we get two decimal place.
When you look at the output fkt. we divide the values through 100!
Executing the test works!

Can you reproduce this?

Thanks
Jochen

-----Original Message-----
From: Andrew Lunn [mailto:andrew@lunn.ch] 
Sent: Montag, 31. Juli 2006 15:42
To: Gerster Jochen-B01096
Cc: ecos-patches@ecos.sourceware.org
Subject: Re: cpuload.cxx patch

> diff -u5prN ecos-trunk-full/ecos/packages/services/cpuload/current/ChangeLog ecos/packages/services/cpuload/current/ChangeLog
> --- ecos-trunk-full/ecos/packages/services/cpuload/current/ChangeLog	2003-02-24 14:34:10.000000000 +0100
> +++ ecos/packages/services/cpuload/current/ChangeLog	2006-07-31 14:27:25.331830900 +0200
> @@ -1,5 +1,8 @@
> +2006-04-21  Jochen Gerster <JochenGerster@gmx.de>
> +	* Average calculation corrected & improved (the bracket wasn't set 
> +correct)
> +
>  2003-02-24  Jonathan Larmour  <jifl@eCosCentric.com>
>  
>  	* cdl/cpuload.cdl: Add doc link.
>  
>  2003-02-20  Bart Veer  <bartv@ecoscentric.com> diff -u5prN 
> ecos-trunk-full/ecos/packages/services/cpuload/current/src/cpuload.cxx ecos/packages/services/cpuload/current/src/cpuload.cxx
> --- ecos-trunk-full/ecos/packages/services/cpuload/current/src/cpuload.cxx	2002-08-19 16:32:08.000000000 +0200
> +++ ecos/packages/services/cpuload/current/src/cpuload.cxx	2006-04-21 10:38:59.603696700 +0200
> @@ -141,15 +141,15 @@ cpuload_alarm_func(cyg_handle_t alarm,cy
>    load = (cyg_uint32) (((cyg_uint64) idle_loops * (cyg_uint64)100) / 
>  		       (cyg_uint64)cpuload->calibration);
>    if (load > 100) {
>      load = 100;
>    }
> -  load = 100 - load;
> +  load = (100 - load)*100;

I've not looked at the patch in detail, but it looks wrong. Maybe im not understanding something which you can explain.

First we have 

>    if (load > 100) {
>      load = 100;
>    }

which implies load is probably between 0 and 100. Then we have

> -  load = 100 - load;
> +  load = (100 - load)*100;

With the old code, load would stay between 0 and 100. With your change, a load of 0 would give 10,000 and a load of 100 would be zero.
This is what does not seem right to me.

What happens when you run the test case?

     Andrew


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