Dear all,
I'm trying to use the pthread_cond_timedwait but this call seems not to be able to suspend the execution and always ends returning ETIMEDOUT.
I've created the condition with the default value for attributes (pthread_cond_init (&mbx->cond, NULL)) also why seems to be impossible set a different value: which system call shoul I use to set them up?
Many thanks
----
This is the method where the problem is shown:
// SendWaitForever wants to copy the pointer p into the circular buffer which is inside of any Mbx class instance
bool Mbx::SendWaitForever (void* p)
{ static const struct timespec forever = {(__time_t) 60*60*24*365*20, 0}; // 20 years
bool retVal;
if (pthread_mutex_lock (&mutex))
return false;
again:
retVal = circBuf.Put(&p);
if (retVal)
pthread_cond_broadcast (&cond);
else {
int retval = pthread_cond_timedwait (&cond, &mutex, &forever);
char *c = strerror(retval);
bool b = ETIMEDOUT == retval;
goto again;
}
pthread_mutex_unlock (&mutex);
return retVal;
}