posix: pthread: pthread_mutex_timedlock should accept absolute deadline
It was coded as if it accepts relative timeout. Normative reference: http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_timedlock.html Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
parent
68c7dc6b96
commit
0906671a7b
2 changed files with 6 additions and 3 deletions
|
@ -224,7 +224,7 @@ int pthread_mutex_unlock(pthread_mutex_t *m);
|
|||
*/
|
||||
|
||||
int pthread_mutex_timedlock(pthread_mutex_t *m,
|
||||
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);
|
||||
|
||||
#define MUTEX_MAX_REC_LOCK 32767
|
||||
|
||||
/*
|
||||
|
@ -73,9 +75,10 @@ int pthread_mutex_trylock(pthread_mutex_t *m)
|
|||
* See IEEE 1003.1
|
||||
*/
|
||||
int pthread_mutex_timedlock(pthread_mutex_t *m,
|
||||
const struct timespec *to)
|
||||
const struct timespec *abstime)
|
||||
{
|
||||
return acquire_mutex(m, _ts_to_ms(to));
|
||||
s32_t timeout = (s32_t)timespec_to_timeoutms(abstime);
|
||||
return acquire_mutex(m, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue