Quality RTOS & Embedded Software

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


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 ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists