Quality RTOS & Embedded Software

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


maximum number of Mutex

Posted by fadillrezha on February 3, 2014

Hi all,

I'm sorry for this trivial question. I am using STM32f407 with STM32 standard peripheral drivers and Keil as development environment.I am currently having a weird problem related to mutex.

I am working based on FreeRTOS and LwIP project provided by ST in http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/PF257896?s_searchtype=keyword.

At first I didn't have any problem, but when I need to add mutexes I found a problem where it seems like there are limit to number of mutex that I can create.

I simply create a mutex, both recursive (xSemaphoreCreateRecursiveMutex)and not(xSemaphoreCreateMutex), and when the number of mutex created is more than a certain number, my code behaves unexpectedly although the mutex is not used anywhere yet. But when I deleted the creation line of one of the mutexes, my code works well. So if I want to make a new mutex after I reach mutex threshold number, I have to delete another mutex, and I conclude that there is a maximum number of mutex that I can create, although I am not sure yet.

I have researched for similar case like mine but can't seem to find one on the internet. If anyone here can confirm about this problem I would really appreciate it. And I wonder what is the physical resource on STM32F/cortex m-4 that is used when a mutex is created?


maximum number of Mutex

Posted by richard_damon on February 3, 2014

Sounds like you are running out of heap memory to create the mutexs. Are you checking the handle to make sure it isn't zero? There is a hook you can define to call a function when you get a heap allocation error which is good for debugging.

maximum number of Mutex

Posted by fadillrezha on February 3, 2014

You are right! This is the answer that I've been looking for. I failed to recognize the fact that RTOS kernel allocates RAM each time a task, queue, mutex, software timer or semaphore is created.

I simply had to increase the configTOTALHEAPSIZE to solve this problem.


[ 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.


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