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

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