RTEMS - rtems_clock_get_uptime() fails during timer tick

Manuel Coutinho manuel.coutinho at edisoft.pt
Fri Feb 25 09:39:07 UTC 2011


Hi all

This problem has been already addressed on another thread:
http://www.rtems.com/ml/rtems-users/2009/march/msg00204.html

Just my 2 cents
Manuel Coutinho

-----Original Message-----
From: rtems-users-bounces at rtems.org [mailto:rtems-users-bounces at rtems.org]
On Behalf Of Rolf Schroedter
Sent: 25 February 2011 09:09
To: Joel Sherrill
Cc: rtems-users at rtems.org
Subject: Re: RTEMS - rtems_clock_get_uptime() fails during timer tick

Hi Joel,
IMO your suggestion to let the nanoseconds handler return a value larger
than a tick is the cleanest solution.
I implemented it for the LEON3 BSP and it seems to work.

Fortunately the LEON3 timer has a InterruptPending(IP) hardware flag
which can be polled and manually reset.
Therefore two changes were necessary:

1. Install a LEON3 timer interrupt handler resetting the IP flag on
every timer tick.
2. Change the LEON3 nanoseconds-handler to check the IP flag:
    read nanoseconds from timer register
    if ( timer_interrupt_pending )
         nanoseconds += timer_tick

I'll post the BSP patch to Jiri Gaisler, shall I also post it here ?

Regards, Rolf

Joel Sherrill wrote, On 24.02.2011 14:28:
> Can the BSP's get nanoseconds handler return a value that is
> more than a clock tick?  This case is just on the edge of
> wrapping the count down timer.  If the counter goes negative,
> does the get nanoseconds since last tick handler in the
> BSP "do the right thing"
>
> On 02/24/2011 01:51 AM, Rolf Schroedter wrote:
>> I tried to protect the call to rtems_clock_get_uptime() from interrupts
>> (this was easier than to recompile RTEMS):
>>
>> #define _get_uptime( _ptr_uptime )        \
>> {                        \
>>       rtems_interrupt_level   _level;        \
>>                           \
>>       rtems_interrupt_disable(_level);        \
>>       rtems_clock_get_uptime( _ptr_uptime );    \
>>       rtems_interrupt_enable(_level);        \
>> }
>>
>> But surprisingly (at least for me) this didn't solve the problem.
>> Okay, I'll try to grab into the RTEMS sources.
>>
>> Thanks&  regards,
>> Rolf.
>>
>>
>> On 24.02.2011 01:23, Gedare Bloom wrote:
>>> Hi,
>>>
>>> I suppose if your code is interrupting the rtems_clock_tick, this
>>> behavior might happen. Can you try to add an ISR_Disable / ISR_Enable
>>> protection around the call to "_Timestamp_Add_to(&_TOD_Uptime,&tick
>>> );" in cpukit/score/src/coretodtickle.c and see if the problem
>>> disappears?
>>>
>>> -Gedare
>>>
>> _______________________________________________
>> rtems-users mailing list
>> rtems-users at rtems.org
>> http://www.rtems.org/mailman/listinfo/rtems-users
>
_______________________________________________
rtems-users mailing list
rtems-users at rtems.org
http://www.rtems.org/mailman/listinfo/rtems-users




More information about the users mailing list