The mutex type
In NBC the mutex type is a 32-bit value that is used to synchronize access to resources shared across multiple threads. For this reason there is never a reason to declare a mutex variable inside a task or a subroutine. It is designed for global variables that all tasks or functions can acquire or release in order to obtain exclusive access to a resource that other tasks or functions are also trying to use.
dseg segment motorMutex mutex dseg ends thread main acquire motorMutex // use the motor(s) protected by this mutex. release motorMutex wait MS_500 endt