76f78fc70953959086f8e37a483fe9107c1e0236 |
|
05-Mar-2018 |
Tom Cherry <tomcherry@google.com> |
Add _monotonic_np versions of timed wait functions As a follow up to Ibba98f5d88be1c306d14e9b9366302ecbef6d534, where we added a work around to convert the CLOCK_REALTIME timeouts to CLOCK_MONOTONIC for pthread and semaphore timed wait functions, we're introducing a set of _monotonic_np versions of each of these functions that wait on CLOCK_MONOTONIC directly. The primary motivation here is that while the above work around helps for 3rd party code, it creates a dilemma when implementing new code that would use these functions: either one implements code with these functions knowing there is a race condition possible or one avoids these functions and reinvent their own waiting/signaling mechanisms. Neither are satisfactory, so we create a third option to use these Android specific _monotonic_np functions that completely remove the race condition while keeping the rest of the interface. Specifically this adds the below functions: pthread_mutex_timedlock_monotonic_np() pthread_cond_timedwait_monotonic_np() pthread_rwlock_timedrdlock_monotonic_np() pthread_rwlock_timedwrlock_monotonic_np() sem_timedwait_monotonic_np() Note that pthread_cond_timedwait_monotonic_np() previously existed and was removed since it's possible to initialize a condition variable to use CLOCK_MONOTONIC. It is added back for a mix of reasons, 1) Symmetry with the rest of the functions we're adding 2) libc++ cannot easily take advantage of the new initializer, but will be able to use this function in order to wait on std::steady_clock 3) Frankly, it's a better API to specify the clock in the waiter function than to specify the clock when the condition variable is initialized. Bug: 73951740 Test: new unit tests Change-Id: I23aa5c204e36a194237d41e064c5c8ccaa4204e3
|
b66a0038ca5c50185270f8a6f2ae67b2580c0833 |
|
19-Feb-2017 |
Elliott Hughes <enh@google.com> |
Fix a comment in the pthread_cond_t implementation. Bug: http://b/34592766 Test: N/A Change-Id: I341f837dca52865ae5f8fe9ff50ba8999e297179
|
a36b574011244d0d3be9eb5bcf1062a3e365299f |
|
14-Jul-2016 |
Yabin Cui <yabinc@google.com> |
Force pthread_cond_timedwait_relative_np using CLOCK_MONOTONIC. Previous patch changed pthread_cond_timedwait_relative_np to use CLOCK_REALTIME, which causes app compatibility problem. So change it back to CLOCK_MONOTONIC. Bug: 30106240 Change-Id: I8e04058e92ede098f4f9f8d133f094001921441e (cherry picked from commit fe4a4d8f67cf84b0b10d6c689f356229e057603b)
|
fe4a4d8f67cf84b0b10d6c689f356229e057603b |
|
14-Jul-2016 |
Yabin Cui <yabinc@google.com> |
Force pthread_cond_timedwait_relative_np using CLOCK_MONOTONIC. Previous patch changed pthread_cond_timedwait_relative_np to use CLOCK_REALTIME, which causes app compatibility problem. So change it back to CLOCK_MONOTONIC. Bug: 30106240 Change-Id: I8e04058e92ede098f4f9f8d133f094001921441e
|
dd586f2ebd0c42904e699f3634568a38c97d4da7 |
|
17-Dec-2015 |
Elliott Hughes <enh@google.com> |
sem_timedwait with a null timeout doesn't mean "forever". It actually means "crash immediately". Well, it's an error. And callers are much more likely to realize their mistake if we crash immediately rather than return EINVAL. Historically, glibc has crashed and bionic -- before the recent changes -- returned EINVAL, so this is a behavior change. Change-Id: I0c2373a6703b20b8a97aacc1e66368a5885e8c51
|
c9a659c57b256001fd63f9825bde69e660c2655b |
|
06-Nov-2015 |
Yabin Cui <yabinc@google.com> |
Use FUTEX_WAIT_BITSET to avoid converting timeouts. Add unittests for pthread APIs with timeout parameter. Bug: 17569991 Change-Id: I6b3b9b2feae03680654cd64c3112ce7644632c87
|
b58457221364eaad039c2c49a42626b725e980d5 |
|
17-Mar-2015 |
Yabin Cui <yabinc@google.com> |
Add test for pthread types alignment check. Bug: 19249079 Change-Id: I83c4f0d11ec5d82a346ae0057d02a92bb1d519e8
|
9e6c7bc61838476d749d9bc4801777d35fd46a63 |
|
16-Mar-2015 |
Yabin Cui <yabinc@google.com> |
Fix atomic_load on const variable in pthread_cond_t. Change-Id: I60f55a53294a09332a3fbec669ed793359d1bdf5
|
32651b8e8e453391c7aaca47cd885e94d54d0bf4 |
|
14-Mar-2015 |
Yabin Cui <yabinc@google.com> |
Hide content of pthread_cond_t in pthread_cond_internal_t. Bug: 19249079 Change-Id: I6f55af30bcd6211ce71630c6cacbef0e1663dcee
|
e5f816c01780220880ee59a29f727c48b51365d3 |
|
29-Jan-2015 |
Yabin Cui <yabinc@google.com> |
Switch pthread_cond_t to <stdatomic.h>. Bug: 17574458 Change-Id: Ic7f79861df4fe751cfa6c6b20b71123cc31e7114
|
04303f5a8ab9a992f3671d46b6ee2171582cbd61 |
|
19-Sep-2014 |
Elliott Hughes <enh@google.com> |
Add semaphore tests, fix sem_destroy. Bug: https://code.google.com/p/android/issues/detail?id=76088 Change-Id: I4a0561b23e90312384d40a1c804ca64ee98f4066
|
2ea60ff0b415ad5b135f498a38c4b56ea75215aa |
|
22-May-2014 |
Elliott Hughes <enh@google.com> |
Remove unnecessary #includes of <sys/atomics.h>. Bug: 14903517 Change-Id: I7b5bcebe58774a441da986cc02376dd88e00ea0e
|
b676aafad04f88e36658d4468054375158dbd3c1 |
|
11-Apr-2014 |
Elliott Hughes <enh@google.com> |
Remove unnecessary #includes. Change-Id: Ie7e0c9ea03f35517c7dcf09fc808c12e55262bc1
|
f0870c3bfeba99482392fafe6d5f49615393c2b1 |
|
21-Feb-2014 |
Halton Huo <halton.huo@intel.com> |
Fix some pthread symbols build as C++ symbol under x64 lunch. Functions protected with !defined(__LP64__) will be get build as C++ symbols for X64 build. This is not the desired work. So protect the implementation with !defined(__LP64__) as well. Change-Id: I4ef50ec36e46289ab308063e24f6c5ac61a6ca8d
|
39b644a0e270df453c53d6060cd364391bb1c512 |
|
04-Mar-2014 |
Elliott Hughes <enh@google.com> |
Remove dead NULL checks from pthread code. GCC is removing these checks anyway because it knows the arguments must be non-null, so leaving this code around is just confusing. We know from experience that people were shipping code with locking bugs because they weren't checking for error returns. Failing hard like glibc does seems the better choice. (And it's what the checked in code was already doing; this patch doesn't change that. It just makes it more obvious that that's what's going on.) Change-Id: I167c6d7c0a296822baf0cb9b43b97821eba7ab35
|
0e714a5b41451e84c5ded93a42c9a4b0a9440691 |
|
04-Mar-2014 |
Elliott Hughes <enh@google.com> |
Implement POSIX pthread_mutex_timedlock. This replaces the non-standard pthread_mutex_lock_timeout_np, which we have to keep around on LP32 for binary compatibility. Change-Id: I098dc7cd38369f0c1bec1fac35687fbd27392e00
|
51e6cb33e3d7c2f44864d356a2a8e66317688f55 |
|
03-Mar-2014 |
Narayan Kamath <narayan@google.com> |
Implement pthread_condattr_{get,set}clock. We only support CLOCK_REALTIME and CLOCK_MONOTONIC for now, so we us a single bit from pthread_cond_t->value to denote the clock type. Note that this reduces the width of the counter to 30 bits, but this should be large enough for all practical purposes. bug: 13232338 Change-Id: I857e7da64b3ecbb23eeac7c9f3fbd460f60231bd
|
9e79af3b61b5a617c537862ebe72248beff58f19 |
|
18-Dec-2013 |
Elliott Hughes <enh@google.com> |
Small style cleanup. Change-Id: Ib45a4a2296232968296f9bd7cc3592ba46fd412d
|
36d6188f8cd8b948fb797f11d9620d63d0c2215a |
|
19-Nov-2013 |
Elliott Hughes <enh@google.com> |
Clean up forking and cloning. The kernel now maintains the pthread_internal_t::tid field for us, and __clone was only used in one place so let's inline it so we don't have to leave such a dangerous function lying around. Also rename files to match their content and remove some useless #includes. Change-Id: I24299fb4a940e394de75f864ee36fdabbd9438f9
|
c3f114037dbf028896310609fd28cf2b3da99c4d |
|
30-Oct-2013 |
Elliott Hughes <enh@google.com> |
<pthread.h> fixes and pthread cleanup. <pthread.h> was missing nonnull attributes, noreturn on pthread_exit, and had incorrect cv qualifiers for several standard functions. I've also marked the non-standard stuff (where I count glibc rather than POSIX as "standard") so we can revisit this cruft for LP64 and try to ensure we're compatible with glibc. I've also broken out the pthread_cond* functions into a new file. I've made the remaining pthread files (plus ptrace) part of the bionic code and fixed all the warnings. I've added a few more smoke tests for chunks of untested pthread functionality. We no longer need the libc_static_common_src_files hack for any of the pthread implementation because we long since stripped out the rest of the armv5 support, and this hack was just to ensure that __get_tls in libc.a went via the kernel if necessary. This patch also finishes the job of breaking up the pthread.c monolith, and adds a handful of new tests. Change-Id: Idc0ae7f5d8aa65989598acd4c01a874fe21582c7
|