Hi all ,
I thought the only differences between a Mutex and a semaphore are the count(Semaphore Capability) and priority inversion(Mutex Capability) .
Today , I’ve encountered something strange which maybe is related to the priority inversion capability or something else .
Getting and releasing Mutex or Semaphores between different tasks is clear but when I use them in just one task , their behavior is different .
Using semaphore the task is locked but using Mutex the task is not locked .
Imagine there is just one task called APP_TestTask
I believe that the problem lies with the inherent definitions of a semaphore and a mutex. If you are using one task then we can assume that, besides the system idle task, that your "APP_TestTask" is the highest priority. Since a mutex incorporates priority inversion, and you also only have one task, the mutex will always fall to the "APP_TestTask". A semaphore, however, is causing problems since you are trying to both give away and take the semaphore from within a task; essentially, you are causing the task to stall.
I have never used a semaphore when I have just one task. Is there a specific reason for why you are doing this?