Quality RTOS & Embedded Software

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


Loading

Mutexes and switching?

Posted by Timothy Bean on February 9, 2009
Couple of quick questions that I did not see a straight answer to:

In regards to priority inversion and priority inheritance. Is
priority inheritance automatic in FreeRTOS, or is it an option that I
need to turn on, and how do I do that if I need to?

I ask because it seems that a mutex is causing my program to freeze.

Also, in regards to switching tasks.

Lets say I am writing to an SD card. Lets say I am writing 512 bytes
to the card, can or will the FreeRTOS scheduler switch while doing
something... ie. in the middle of a command?

Thanks

Tim

RE: Mutexes and switching?

Posted by Richard on February 9, 2009
> In regards to priority inversion and priority inheritance.
> Is priority inheritance automatic in FreeRTOS, or is it an
> option that I need to turn on, and how do I do that if I need to?
>

Priority inheritance is automatic if you are using a Mutex type semaphore - created with the xSemaphoreCreateMutex() API function. The only difference between binary semaphores and mutexes is that mutexes have this extra functionality.

Note that the priority inheritance mechanism assumes that only one mutex will be held by a task at any one time.


> I ask because it seems that a mutex is causing my program to freeze.

Freeze in what sense? Completely crash? Or wait for the semaphore indefinitely?

>
> Also, in regards to switching tasks.
>
> Lets say I am writing to an SD card. Lets say I am writing
> 512 bytes to the card, can or will the FreeRTOS scheduler
> switch while doing something... ie. in the middle of a command?

FreeRTOS knows nothing about what your application is doing, or how your SD card driver and file system operate. The tick interrupt will continue to function as long as interrupts remain enabled (not in a critical section). Interrupts will also continue, but not perform a context switch, if the scheduler is suspended (vTaskSuspendAll() has been called). In the latter case context switches are held pending until the scheduler is unsuspended.

Regards.


RE: Mutexes and switching?

Posted by Timothy Bean on February 22, 2009
The OS and everything completely crashes and stops running.

Here is the scenario:

Task A uses the SPI bus.
Task B also uses the SPI bus.
Again with Task C.

Task A can take the semaphore, no problems. Always works.

If Task B or Task C tries to take the semaphore, the whole OS crashes. Every time, even is Task A is not doing anything at the moment.


[ 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