This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS570LC4357:使用较新 FreeRTOS 版本时的性能问题

Guru**** 2392905 points
Other Parts Discussed in Thread: HALCOGEN, TI-CGT, TMS570LC4357, RM46L852

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1430476/tms570lc4357-performance-issues-using-newer-freertos-versions

器件型号:TMS570LC4357
主题中讨论的其他器件:HALCOGENTI-CGT、、 RM46L852

工具与软件:

您好!

我们在 TMS570CL435上使用 FreeRTOS。 该处理器基于 ARM R5。 由于没有用于这一用途的 FreeRTOS 端口、我们将根据 R4端口和提供的 HalCoGen 代码来编写我们自己的端口。 由于 HalCoGen 只支持较旧的 FreeRTOS 版本、我们 必须 自行调整。
目前、我们正在从10.4.5版升级。 更新至最新版本。 我们通过测量空闲时间发现了显著的性能损失。

修补程序版本

空闲%

10.4.5.

44%

10.4.6.

40%

10.5.0

33%

 

通过跟踪此问题、我们注意到 portasm.asm 和  portmacro.h 文件中有一处更改

 

FreeRTOS v10.4.5。 portasm.asm:

 

; start: required for Cortex-R5 MPU port - generated by TI HALCoGen - see src/os/freertos/README.ti-halcogen.md for details

;-------------------------------------------------------------------------------

        .def ulPortCountLeadingZeros

        .asmfunc

ulPortCountLeadingZeros

        CLZ     R0, R0

        BX      LR

        .endasmfunc

 

FreeRTOS v10.4.5。 portmacro.h:

/* Generic helper function. */

    unsigned long ulPortCountLeadingZeros( unsigned long ulBitmap );

    #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities )    uxTopPriority = ( 31 - ulPortCountLeadingZeros( ( uxReadyPriorities ) ) )

 

FreeRTOS v10.4.6。 portasm.asm:

 ; Function removed

 

FreeRTOS v10.4.6。 portmacro.h:

 #define portGET_HIGTH_PRIORITY ( uxTopPriority、uxReadyPriorities ) uxTopPriority  =( 31 -__clz ( uxReadyPriority )))

当我们在不调用的情况下返回汇编器代码时、性能恢复为 V10.4.5的值。 然而,如果将其集成到 V10.5.0中,性能会下降。 我们使用的是 TI-CGT 20.2.7编译器、默认使用-o3优化。 如果没有对-o0进行编译器优化、V10.4.5和 V10.4.6之间的差异将消失、但 V10.5.0的问题仍然存在。  
在 V10.5.0版中、FreeRTOS 在 MPU_wrappers.c 中引入了 if 语句、用于检查我们是否处于特权模式:

 

 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )

        TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,

                                            const char * const pcName,

                                            const uint32_t ulStackDepth,

                                            void * const pvParameters,

                                            UBaseType_t uxPriority,

                                            StackType_t * const puxStackBuffer,

                                            StaticTask_t * const pxTaskBuffer ) /* FREERTOS_SYSTEM_CALL */

        {

            TaskHandle_t xReturn;

            if( portIS_PRIVILEGED() == pdFALSE )

            {

                portRAISE_PRIVILEGE();

                portMEMORY_BARRIER();

                uxPriority = uxPriority & ~( portPRIVILEGE_BIT );

                portMEMORY_BARRIER();

                xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );

                portMEMORY_BARRIER();

                portRESET_PRIVILEGE();

                portMEMORY_BARRIER();

            }

            else

            {

                xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );

            }

            return xReturn;

        }

    #endif /* configSUPPORT_STATIC_ALLOCATION */

 

在该查询之前、swiRaisePrivilege 的汇编代码使其更加高效。
 
其他人是否遇到过同样的问题、或者有人知道 MPU_wrappers 发生变化的原因吗?

我附加了3个 FreeRTOS 版本的代码。

此致、谢谢。  
斯文

 e2e.ti.com/.../freertosV10.4.5.zipe2e.ti.com/.../freertosV10.4.6.zipe2e.ti.com/.../freertosV10.5.0.zip