This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

mutex for global variable access



Hello, TIRTOS newbie here. 

I have a global variable that is periodically updated by a task. Meanwhile, other tasks may want to read the value of this global variable at random intervals. What is the recommended may in TIRTOS to make sure access to this global variable is thread safe? Is there a mutex lock/unlock equivalent? 

I have seen examples of semaphore pend/post but i can't quite understand how they apply to the context i described above. 

Thanks in advance.

  • Hi pixbroker,
    You could use either a GateMutex or a Semaphore. To see a Semaphore example, check out the TI-RTOS Kernel example, "Task Mutex Example". This example uses a semaphore to protect a global variable. GateMutex would also work and allows a task to enter the gate multiple times, which you may not need.
    Best regards,
    Janet