On the page you link to, "mutex" is the actual low-level synchronization primitive. You can take a mutex and then let it go, and only one thread can take it at any time (therefore, this is a synchronization primitive). A recursive mutex is one that can be taken by the same stream several times, and then it must be released so many times by the same stream before others can accept it.
The “lock” here is just a C ++ wrapper class that takes a mutex in its constructor and releases it in the destructor. This is useful for setting synchronization for C ++ areas.
A state variable is a more advanced / higher-level form of a synchronization primitive that combines a lock with a signaling mechanism. It is used when threads must wait for a resource to become available. The thread can wait on the CV, and then the resource producer can signal this variable, in which case the threads waiting for the resume will be notified and may continue to execute. A mutex is combined with a CV to avoid a race condition when a thread starts to wait on a CV while another thread wants to signal it; then it is not controlled whether the signal will be delivered or lost.
Antti Huima Jun 28 '09 at 18:28 2009-06-28 18:28
source share