Quality RTOS & Embedded Software

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


malloc/free thread & interrupt-safe

Posted by Joe on April 9, 2007
Hi @all,

I am using the arm7-gcc port of FreeRTOS with the Aeolus-newlib syscall-stub with some modifications and it works fine. But now I have a question concerning the malloc/free-mechanism during interrupts. At the moment i also use the heap_3.c module which uses the standard-malloc/free because I do not have hard deterministic requirements. But I unsure if this malloc/free (sbrk_r) also works during interrupts and if it is thread safe.
Does anyone know more about my requirements or does someone have a solution for my question ?


RE: malloc/free thread & interrupt-safe

Posted by Nobody/Anonymous on April 9, 2007
You cannot use pvPortMalloc or vPortFree from an interrupt because they use critical sections to ensure they are thread safe. You could use standard malloc and free from an interrupt, provided you only use the thread safe versions from outside of the interrupt.

However, generally it would be considered bad practice to call such a potentially large and non deterministic function such as malloc from within an interrupt in any case.


RE: malloc/free thread & interrupt-safe

Posted by Joe on April 9, 2007
Ok, I will check another way to implement my requirements. You have right with the statement of bad practise, may be i will check the possiblity using preallocated blocks


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

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

Latest News

Meet Richard Barry and learn what's new in the FreeRTOS project at Embedded World 2019

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

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.


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



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