diff options
| author | David 'Digit' Turner <digit@google.com> | 2010-03-10 16:44:08 -0800 |
|---|---|---|
| committer | David 'Digit' Turner <digit@google.com> | 2010-03-11 11:48:38 -0800 |
| commit | ba9c6f0989ae94778ba2b9f597adc827c9dc81e8 (patch) | |
| tree | 2376f2a87f6ac304bd93beca7c8139b890a6227f /libc/arch-sh/bionic/atomics_sh.c | |
| parent | 1cfbda826ce66e9bd1507a31b7e6df62e0dbcc6e (diff) | |
| download | bionic-ba9c6f0989ae94778ba2b9f597adc827c9dc81e8.zip bionic-ba9c6f0989ae94778ba2b9f597adc827c9dc81e8.tar.gz bionic-ba9c6f0989ae94778ba2b9f597adc827c9dc81e8.tar.bz2 | |
bionic: pthread: use private futexes by default for mutexes and condvars
Private futexes are a recent kernel addition: faster futexes that cannot be
shared between processes. This patch uses them by default, unless the PROCESS_SHARED
attribute flag is used when creating a mutex and/or conditional variable.
Also introduces pthread_condattr_init/destroy/setpshared/getpshared.
Change-Id: I3a0e2116f467072b046524cb5babc00e41057a53
Diffstat (limited to 'libc/arch-sh/bionic/atomics_sh.c')
| -rw-r--r-- | libc/arch-sh/bionic/atomics_sh.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libc/arch-sh/bionic/atomics_sh.c b/libc/arch-sh/bionic/atomics_sh.c index 16966f7..5171363 100644 --- a/libc/arch-sh/bionic/atomics_sh.c +++ b/libc/arch-sh/bionic/atomics_sh.c @@ -98,3 +98,21 @@ int __futex_wake(volatile void *ftx, int count) { return futex(ftx, FUTEX_WAKE, count, NULL, NULL, 0); } + +/* Private futexes belong to a single address space and cannot be + * shared among processes. They are however significantly faster to + * operate than standard futexes. + */ +#define FUTEX_PRIVATE_FLAG 128 +#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT|FUTEX_PRIVATE_FLAG) +#define FUTEX_WAKE_PRIVATE (FUTEX_WAKE|FUTEX_PRIVATE_FLAG) + +int __futex_wait_private(volatile void *ftx, int val, const struct timespec *timeout) +{ + return futex(ftx, FUTEX_WAIT_PRIVATE, val, (void *)timeout, NULL, 0); +} + +int __futex_wake_private(volatile void *ftx, int count) +{ + return futex(ftx, FUTEX_WAKE_PRIVATE, count, NULL, NULL, 0); +} |
