Quality RTOS & Embedded Software

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




Loading

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 ?

regards
Joe

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.

Dave.

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

Joe


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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