I have two tasks that share a recursive mutex in freertos.
Low priority task A protects some critical code with the mutex taking it at the start of its main loop and releasing it at the end.
High priority task B sometimes, very seldomly, maybe once per boot cycle, needs to wait for the mutex and run something when the lower one is not in the critical section. Not sure if this matters, this happens in a branch of a function that’s constantly running.
My initial assumption was that A priority would be raised only when the B would try to take the mutex. What I’m seeing though is that as soon as A takes the mutex priority is promptly raised to B one.
It seems somehow it knows that priority inversion might happen and it’s proactive about it. If I comment out the mutex take in B, A priority stays low. If I never take the mutex from B but leave the code active, A priority is raised.
I’m still trying to debug this, is this scenario plausible or should I dig more? how does the OS know the mutex can or cannot be taken? can this behaviour be configured?