mx: Mutex functions
|Top Previous Next|
The mutex (Mutual Exclusion) data type is most importantly used for implementing critical sections in a multithreading VPL program. Critical sections are used in the cases where more than one thread is accessing the same shared resource - like a global variable/data structure accessed from several threads.
When using a mutex, it is ensured that only one thread will be executing in the critical section at one time. Other threads that also want to enter the critical section will be blocked until the thread executing in the critical section leaves it. Please also see the section on thread synchronization.
Before a mutex variable can be used, it must be initialized by using the mxInit() function. When requesting ownership of the mutex (when entering a critical section), the function mxLock() must be called. When releasing ownership of the mutex (when leaving a critical section), the function mxUnlock() must be called.
The following mutex functions exists: