[BUG] common_tmr.c

classic Classic list List threaded Threaded
2 messages Options
Markus Korber Markus Korber
Reply | Threaded
Open this post in threaded view
|

[BUG] common_tmr.c

Hello,

I think I've found a bug in common_tmr.c (see possible patch below).
There might be a timer IRQ between setting tempcnt (whose value is then
close to cmn_systimer_us_per_interrupt) and tempsys.  This results in a
crtsys value jump because tempcnt is added to the *updated*
cmn_systimer_counter.

Switching the two lines should circumvent this problem.  A tempcnt
wrap-around (and thus an IRQ) might nevertheless occur between setting
tempsys and tempcnt but we handle this case anyway.


diff --git a/src/common_tmr.c b/src/common_tmr.c
--- a/src/common_tmr.c
+++ b/src/common_tmr.c
@@ -417,8 +417,8 @@
 {
   u64 tempsys, tempcnt, crtsys;
 
+  tempsys = cmn_systimer_counter;
   tempcnt = platform_timer_sys_raw_read();
-  tempsys = cmn_systimer_counter;
   while( ( crtsys = cmn_systimer_counter ) != tempsys )
   {
     tempcnt = platform_timer_sys_raw_read();


Regards,
Markus Korber

_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] common_tmr.c

Hi,

On Tue, Sep 11, 2012 at 2:31 PM, Markus Korber <[hidden email]> wrote:

> Hello,
>
> I think I've found a bug in common_tmr.c (see possible patch below).
> There might be a timer IRQ between setting tempcnt (whose value is then
> close to cmn_systimer_us_per_interrupt) and tempsys.  This results in a
> crtsys value jump because tempcnt is added to the *updated*
> cmn_systimer_counter.
>
> Switching the two lines should circumvent this problem.  A tempcnt
> wrap-around (and thus an IRQ) might nevertheless occur between setting
> tempsys and tempcnt but we handle this case anyway.

Thanks for the report! We'll fix this soon.

Best,
Bogdan

>
>
>
> Regards,
> Markus Korber
>
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev