Quality RTOS & Embedded Software

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


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


Careers

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

Renesas

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