sdm: Handle spurious wakeup from pthread_cond_wait

SDM uses entry/exit lock in draw thread to prevent other threads from
executing in between prepare/set phases. However, waiting threads may
be woken up from pthread_cond_wait "spuriously" and if they don't
re-evaluate the predicate, they could execute when they shouldn't.

To quote the Holy Man Page for pthread_cond_wait:
"When using condition variables there is always a Boolean predicate
involving shared variables associated with each condition wait that
is true if the thread should proceed. Spurious wakeups from the
pthread_cond_timedwait() or pthread_cond_wait() functions may occur.
Since the return from pthread_cond_timedwait() or pthread_cond_wait()
does not imply anything about the value of this predicate, the
predicate should be re-evaluated upon such return"

Change-Id: I812a19b151fce719653055a0136e3c8da455b70c
CRs-fixed: 1010600
1 file changed