I guess the problem is on my side, but you may enlight me.
Code: Select all
main { // priority default + 0
..
chMtxLock(&mutex);
chCondWait(&condVar);
doSomething();
chMtxUnlock();
..
}
Code: Select all
thread { // priority default+1
..
if (chMtxTryLock(&mutex) == FALSE) {
// a) never gets here <====
doBeforeSomething();
chCondSignal(&condVar);
chMtxLock(&mutex);
doAfterSomething();
}
else {
// b)
doSomethingElse();
}
chMtxUnlock();
..
}
What I expect:
If mutex not locked in main: case b) is run in thread.
If mutex is locked in main and waiting for condVar: case a) is run in thread.
What I get:
b) is always run in thread.
Why?
I want doBeforeSomething(), then doSomething(), then doAfterSomething() OR doSomethingElse(). nThanks for help.