diff options
| author | Tom Cherry <tomcherry@google.com> | 2017-08-17 13:18:52 -0700 |
|---|---|---|
| committer | Tom Cherry <tomcherry@google.com> | 2017-08-18 09:11:05 -0700 |
| commit | ac49cedc7e2bab2073a0895ef01e31dac84f590b (patch) | |
| tree | 49713323bcf5e81e429e669e359bd99021d771e6 /libc/malloc_hooks/tests/malloc_hooks_tests.cpp | |
| parent | 30438e4cea83628bcacbedff37a35398bb8b40e7 (diff) | |
Always use CLOCK_MONOTONIC for pthreads and semaphores
pthread's and semaphore's default behavior is to use CLOCK_REALTIME,
however this behavior is essentially never intended, as that clock is
prone to change discontinuously.
What users really intend is to use CLOCK_MONOTONIC, however only
pthread_cond_timedwait() provides this as an option and even there, a
large amount of existing code does not opt into CLOCK_MONOTONIC.
We have seen numerous bugs directly attributable to this difference.
Therefore, we provide this general workaround to always use
CLOCK_MONOTONIC for waiting, regardless of what the input timespec
is.
Specifically this impacts the below APIs:
pthread_mutex_timedlock()
pthread_cond_timedwait()
pthread_rwlock_timedrdlock()
pthread_rwlock_timedwrlock()
sem_timedwait()
Test: boot bullhead, boot sailfish
Test: bionic pthread/semaphore unit tests
Test: check that pthread_cond_timedwait() timeouts are uneffected by
CLOCK_REALTIME time changes
Bug: 64694413
Bug: 64623895
Bug: 35756266
Bug: 35678943
Change-Id: Ibba98f5d88be1c306d14e9b9366302ecbef6d534
Diffstat (limited to 'libc/malloc_hooks/tests/malloc_hooks_tests.cpp')
0 files changed, 0 insertions, 0 deletions
