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




Loading

Mutex not working

Posted by Dave Neale on December 26, 2010
I am not sure if I am correct, but a Mutex should be just that - Mutual Exclusion. If I take a mutex then no other call for that same mutex should succeed until I give the mutex back. This does not work with existing mutex implementation, as the mutex is implemented as a recursive semaphore. I have a mutex to protect the use of a serial port that is used by more than one task.
The messages that are sent on that port are mixed segments of messages from the multiple tasks.
Does anyone have a fix for this ? If not I will fix this and post the fix.

RE: Mutex not working

Posted by Richard on December 26, 2010
“If I take a mutex then no other call for that same mutex should succeed until I give the mutex back.”


Agreed.
“This does not work with existing mutex implementation”


? I think it does. The three mutex tasks that are implemented in the standard demo GenQTest.c file test the behaviour. Do you have a test case where it does not work as intended?

“as the mutex is implemented as a recursive semaphore”


? No it isn't.....a mutex is in effect a binary semaphore with the added functionality of priority inheritance - created using the xSemaphoreCreateMutex() API function. The recursive mutex implementation is quite separate, recursive mutexes are created using the xSemaphoreCreateRecursiveMutex() API function. A task cannot take a recursive mutex if it is held by another task, and cannot give one back unless it is already the mutex holder.

“Does anyone have a fix for this ? If not I will fix this and post the fix”


I'm not convinced there is a problem, so please demonstrate the problem and get agreement that it exists before trying to fix it. If there is a problem then posting a fix would be appreciated, although the bug tracker might be a better place to post it.

Regards.


[ 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