A conditional variable is used to block and object until it is “notified” to makeup. To use conditional variables, we need to use below header: #include <condition_variable> // std::condition_variable Conditional variable uses unique_lock to lock a thread when one of its wait functions is called. Then …
In the previous chapter we learn about timed_mutex, in this chapter we shall learn about recursive_mutex. Need for recursive mutex? Suppose there is a recursive function that acquires lock before calling itself as shown below: recursive_function() { . . . m.lock(); recursive_function(); m.unlock(); } Now the …
In the previous chapters we learnt about Mutex, Race condition and critical section. In this chapter we shall learn about timed mutex. Generally in a mutex, when one thread tries to acquires a lock , that has already been locked by another thread , current thread …
In the previous chapter we learn about mutex. In this chapter we shall learn about try_lock member function in mutex. As explained in the previous statement, try_lock is a member function of mutex class. There are different types of try_lock functions available. They are: There are …
Mutex stands for Mutual Exclusion. What is mutual exclusion? To answer this question, we need to understand what is Race Condition? A race condition is a situation where two or more threads or process trying to modify the data at the same time. Race condition occurs …