[rtems commit] riscv: Implement CPU counter

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jul 16 05:18:46 UTC 2018


On 13/07/18 11:48, Hesham Almatary wrote:
> On Thu, Jul 12, 2018 at 9:41 PM, Sebastian Huber
> <sebastian.huber at embedded-brains.de> wrote:
>>
>>
>> ----- Am 6. Jul 2018 um 15:11 schrieb Hesham Almatary heshamelmatary at gmail.com:
>>
>>> On Fri, 6 Jul 2018 at 1:28 pm, Sebastian Huber <sebh at rtems.org> wrote:
>> [...]
>>>> -CPU_Counter_ticks _CPU_Counter_read( void );
>>>> +static inline CPU_Counter_ticks _CPU_Counter_read( void )
>>>> +{
>>>> +  unsigned long ticks;
>>>> +
>>>> +  __asm__ volatile ( "rdtime %0" : "=&r" ( ticks ) );
>>>> +
>>> Shouldn’t this be “rdcycle” instead of “rdtime”?
>> The rdcycle is affected by power saving states. If you want to use the CPU counter for fast timestamps, then this is bad.
> I agree. However, if we just want to read cycles/ticks (for
> performance monitoring) by calling this function, "rdtime" wouldn't
> report the desired result** in tthis case.
>
>
> ** From the spec: "The execution environment should provide a means of
> determining the period of the real-time counter (seconds/tick)"

The real-time counter is suitable for performance monitoring. However, 
since its frequency is probably not equal to the processor frequency it 
is not as good as the cycle counter. To fix this problem we would need a 
new CPU port function, e.g. _CPU_Get_timestamp(), in addition to 
_CPU_Counter_read().

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list