
Multitask and semaphore problem
Hi all,
I'm doing a robot project. In the program, I have two tasks who need to access the same set of variables. To secure synchronization, I use a semaphore to protect the critical section as below code. However, when the two tasks are executing concurrently, it appears one of them always defeats another and "hogs" the semaphore, instead of the expected time-sharing behavior. The two tasks should have the same default priority that I haven't specified. Do you suggest any cause?