Quality RTOS & Embedded Software

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


vEventGroupDelete and heaps

Posted by hawk777 on March 10, 2014

Hi! I noticed something odd in my application today. I wrote some code that called vEventGroupDelete, and it crashed. I discovered this is why: my heap implementation uses a mutex (it seemed like an obvious idea at the time) as a heap lock (I use the Newlib malloc/free functions with _malloclock and _mallocunlock implemented on top of xSemaphoreTakeRecursive and xSemaphoreGiveRecursive respectively). vEventGroupDelete, however, calls vPortFree with the scheduler disabled, which of course fails—you can’t go to sleep to take a semaphore while the scheduler is disabled!

I notice that heap_3 in MemMang, the closest example code, suspends the scheduler while accessing the heap rather than using a mutex. However, I also noticed that the other basic synchronization primitive, the queue, does NOT try to access the heap with the scheduler disabled in vQueueDelete.

Thus my question: is this supposed to work? Is it a bug, meaning that vEventGroupDelete ought to be calling vPortFree after xTaskResumeAll? Or is this not a bug, and vPortMalloc/vPortFree must be safe to call with the scheduler disabled?

vEventGroupDelete and heaps

Posted by rtel on March 10, 2014

It is a usage scenario that doesn't exists is the official code base, so I would not say it was supposed to work, but equally we want the code to be as easy to use with the widest set of scenarios as possible, so I would also say it is not supposed to not work. We will take a look and see what can be done.


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

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

Latest News

FreeRTOS v10.2.1 is available for immediate download. MIT licensed, includes 64-bit RISC-V, NXP Cortex-M33 demo, Nuvoton Cortex-M23 demo & STM32H745 dual core (AMP) demo.

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

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

Cadence Tensilica Cortes

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