posix: pthread: pthread_cond_timedwait should accept absolute deadline
Instead, it was coded as if it accepted a relative timeout. Normative reference: http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_timedwait.html Fixes: #17812 Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
parent
3f93f89558
commit
68c7dc6b96
2 changed files with 6 additions and 3 deletions
|
@ -124,7 +124,7 @@ int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut);
|
|||
* See IEEE 1003.1
|
||||
*/
|
||||
int pthread_cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *mut,
|
||||
const struct timespec *to);
|
||||
const struct timespec *abstime);
|
||||
|
||||
/**
|
||||
* @brief POSIX threading compatibility API
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <wait_q.h>
|
||||
#include <posix/pthread.h>
|
||||
|
||||
s64_t timespec_to_timeoutms(const struct timespec *abstime);
|
||||
|
||||
static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut, int timeout)
|
||||
{
|
||||
__ASSERT(mut->lock_count == 1U, "");
|
||||
|
@ -73,8 +75,9 @@ int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut)
|
|||
}
|
||||
|
||||
int pthread_cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *mut,
|
||||
const struct timespec *to)
|
||||
const struct timespec *abstime)
|
||||
{
|
||||
return cond_wait(cv, mut, _ts_to_ms(to));
|
||||
s32_t timeout = (s32_t)timespec_to_timeoutms(abstime);
|
||||
return cond_wait(cv, mut, timeout);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue