Re: Doubts about GThreads





On Tue, May 18, 2010 at 9:12 AM, Iñigo Martínez <martinez i ikusi com> wrote:

I mean, before waiting on a condition, is usual to lock the mutex used
on the condition, so if the thread is waiting and the mutex locked,
another thread will not be able to lock the same mutex to wake up the
thread with cond, blocking each other.

and to clarify this point: when a thread blocks ("sleeps") in order to wait for a condition, it releases the mutexes that was passed to g_cond_wait(). then, before it is woken again, the thread system reacquires the mutex on behalf of the thread, so that when it returns from g_cond_wait(), the mutex it held again.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]