Mutexes and switching?

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

Mutexes and switching?

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

Mutexes and switching?

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.