Conditional waits

lambert54_at_cox.net
Date: 09/28/05


Date: 28 Sep 2005 13:03:08 -0700

If I defined global vars as:
1) pthread_mutex_t CtrlThrdSem = PTHREAD_MUTEX_INITIALIZER;
2) pthread_cond_t CtrlThrdCond = PTHREAD_COND_INITIALIZER;

have my main thread basically doing:

3) pthread_mutex_lock ( &CtrlThrdSem );
4) ... start thread, do stuff ...
5) time(&timebuf.tv_sec);
6) timebuf.tv_sec += HA_CTRLTHRD_TIMEOUT;
7) timebuf.tv_nsec = 0L;
8) pthread_cond_timedwait(&CtrlThrdCond, &CtrlThrdSem, &timebuf);

and another thread doing:
9) pthread_cond_signal ( &CtrlThrdCond );

What will happen if line 9 gets performed before line 8 is called?
Shouldn't it just drop on through the call or is there a possiblity of
not picking up the condition?