Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

GCC/ARM_CM4F wasted word on main stack

Posted by hawk777 on November 4, 2013

Hi! Looking at the GCC/ARM_CM4F target port.c xPortPendSVHandler, I believe a word of stack space is wasted pushing r14 (the link register) on the main stack, this being done on line 449 in the 7.5.3 release. It looks like this code was copied from the CM3 target, where the push of r14 in that instruction made sense, as the exception return value was the same for all tasks and so could simply be saved on the main stack between call and return of vTaskSwitchContext. In the CM4F, on the other hand, different tasks have different exception return values depending on whether or not the task uses the FPU; as such, the push on line 445 saving the callee-save integer registers onto the process stack was extended to include the link register, r14, and the corresponding load on line 460 updated to match. However, because r14 is saved on the process stack, I believe there is no longer any reason to save it on the main stack on line 449 and restore it on line 455; certainly the LR is never used between line 455 when restored the first time and line 460 when restored the second time! This is just wasting a word of main stack space, and a little bit of CPU time, for on benefit, as far as I can tell.


GCC/ARM_CM4F wasted word on main stack

Posted by richardbarry on November 4, 2013

Looks like you could be right. I will test it with the additional push/pop removed.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner