History log of /fuchsia/zircon/third_party/ulib/musl/src/thread/cnd_timedwait.c
Revision Date Author Comments
# 24c65445 26-Feb-2018 George Kulakowski <kulakowski@google.com>

[libc] Rename pthread_impl.h to threads_impl.h

Baby step towards separating pthreads out of libc

Change-Id: Ibb1ba6656c796218909f4a3451db9bb66b99fb80


# f3e2126c 12-Sep-2017 Roland McGrath <mcgrathr@google.com>

[zx] Magenta -> Zircon

The Great Renaming is here!

Change-Id: I3229bdeb2a3d0e40fb4db6fec8ca7d971fbffb94


# de4889d2 02-Aug-2017 George Kulakowski <kulakowski@google.com>

[musl] Deduplicate the requeue-ing lock abstraction that condvars use

Change-Id: I95319f957f8190420e1c3ddc2a67f25facaf6ece


# 9f01bc3a 01-Aug-2017 George Kulakowski <kulakowski@google.com>

[musl][condvars] Name some constants in internal condvar locks

Change-Id: Ieb12cb0d5af5d59c1add1cb80bd990b8e4da8550


# abd6594a 22-Mar-2017 George Kulakowski <kulakowski@google.com>

[musl][pthread] Remove pthread cancellation machinery

Nothing currently in Fuchsia uses this, nor am I aware of any 2nd or
3rd party code that is likely to. I do not believe that, if someone
were to attempt to truly implement pthread_cancel etc. on Magenta,
that the removal of this code and comments would be a meaningful
impediment.

Change-Id: Ib8435a68d0b053ba3f1d0590640ef54c23e59840


# 71d6d1b9 20-Mar-2017 George Kulakowski <kulakowski@google.com>

[musl][condvar] Remove unneeded void* casts in condvar code

Change-Id: I2f2bab298a0b7509cb129419b9a5b6b362953882


# a2365daa 15-Feb-2017 George Kulakowski <kulakowski@google.com>

[musl][atomics] Use C11 atomics in public types

Change-Id: Ie684384c127d881fbeccb1290adce622d368d136


# ab434f7f 15-Feb-2017 James Robinson <jamesr@google.com>

Revert "[musl][atomics] Use C11 atomics in public types"

This reverts commits f2373edae22bc921a41286318243b3985102b510 and
c97bbfb0755f81841769a12a12ba5fbe86144a6b

This breaks libc++ builds:

FAILED: src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o
/b/swarm_slave/w/irzvTVgH/kitchen-workdir/buildtools/toolchain/clang+llvm-x86_64-linux/bin/clang++ -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libunwind/include -I/b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libcxx/include -stdlib=libc++ -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -fcolor-diagnostics -target x86_64-fuchsia --sysroot=/b/swarm_slave/w/irzvTVgH/kitchen-workdir/out/sysroot/x86_64-fuchsia -std=c++11 -g -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wno-unused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -pedantic -D_DEBUG -D_LIBUNWIND_IS_NATIVE_ONLY -fPIC -fno-exceptions -funwind-tables -I/b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libcxx/include -stdlib=libc++ -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -fcolor-diagnostics -target x86_64-fuchsia --sysroot=/b/swarm_slave/w/irzvTVgH/kitchen-workdir/out/sysroot/x86_64-fuchsia -std=c++11 -fstrict-aliasing -fno-rtti -MD -MT src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o -MF src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o.d -o src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o -c /b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libunwind/src/libunwind.cpp
In file included from /b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libunwind/src/libunwind.cpp:19:
In file included from /b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libcxx/include/algorithm:640:
In file included from /b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libcxx/include/memory:643:
/b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libcxx/include/atomic:1713:17: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile bool *' invalid)
{return __c11_atomic_exchange(&__a_, true, __m);}
^ ~~~~~
/b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libcxx/include/atomic:1716:17: error: address argument to atomic operation must be a pointer to _Atomic type ('bool *' invalid)
{return __c11_atomic_exchange(&__a_, true, __m);}
^ ~~~~~
/b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libcxx/include/atomic:1719:10: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile bool *' invalid)
{__c11_atomic_store(&__a_, false, __m);}
^ ~~~~~
/b/swarm_slave/w/irzvTVgH/kitchen-workdir/third_party/llvm/runtimes/libcxx/include/atomic:1722:10: error: address argument to atomic operation must be a pointer to _Atomic type ('bool *' invalid)
{__c11_atomic_store(&__a_, false, __m);}

Change-Id: I2fba5de2b1abc16f6e2ab3ae11f4b6ee1e70f135


# f2373eda 10-Feb-2017 George Kulakowski <kulakowski@google.com>

[musl][atomics] Use C11 atomics in public types

For now, use a shim around compare and swap. Followup patches will
rewrite them directly into the C11 style, but for now minimize noise.

Change-Id: Idf3626fea6318b8508d6e65f2634a71e93cf866c


# 7cd57a3e 07-Feb-2017 Mark Seaborn <mseaborn@google.com>

[runtime] Make mxr_mutex more efficient: change from 2-state lock to 3-state

This is a standard 3-state futex-based locking algorithm. See the
comment.

This requires updating the C11 cnd_* (condvar) implementation to
match.

This change means that mxr_mutex_unlock() won't do a futex_wake()
syscall in the uncontended case (when there are no waiting threads).

Also, mxr_mutex_unlock() will now wake only one thread at a time.
Previously, it would wake all waiting threads (though that was
unnecessary, even with a 2-state lock).

This also affects the C11 mtx_* implementation, which uses mxr_mutex.

This is a modified version of e4ae71336ad8b56b53aa5cb385374610b284c6a6
with MG-487 fixed: cnd_timedwait() must do
mxr_mutex_lock_with_waiter() unconditionally to ensure that threads
waiting on the mutex will get woken later.

MG-361

Change-Id: I94733d3a26c05852d34ce5c6571511c3e3e55456


# 95d15cbf 07-Feb-2017 Mark Seaborn <mseaborn@google.com>

[musl] Add explanatory comments to pthread_cond_timedwait() and cnd_timedwait()

The algorithm used by Musl's condvar implementation is quite complex
and subtle, and the implementation is cryptic with little explanation.

This change adds some explanation of how the algorithm works.

cnd_timedwait() has a duplicate implementation, so I've copied the
comments there too, changing the pthread_*() references to refer to
mxr_mutex_*() and cnd_*() instead.

MG-361

Change-Id: I9023435f6a629a398ccfcf3729b7a9d865ed0a53


# 496fe303 01-Feb-2017 Mark Seaborn <mseaborn@google.com>

Revert "[runtime] Make mxr_mutex more efficient: change from 2-state lock to 3-state"

This reverts commit e4ae71336ad8b56b53aa5cb385374610b284c6a6.

That change introduced a bug in the interaction between the mutex
implementation and the condvar implementation
(third_party/ulib/musl/src/thread/cnd_timedwait.c) which could lead to
missed mutex_unlock wakeups. That could cause c11-condvar-test to
hang.

MG-487 #done

Change-Id: I1519733e66330da27707ebb6b8a8c111f290ca73


# e4ae7133 24-Jan-2017 Mark Seaborn <mseaborn@google.com>

[runtime] Make mxr_mutex more efficient: change from 2-state lock to 3-state

This is a standard 3-state futex-based locking algorithm. See the
comment.

This requires updating the C11 cnd_* (condvar) implementation to
match.

This change means that mxr_mutex_unlock() won't do a futex_wake()
syscall in the uncontended case (when there are no waiting threads).

Also, mxr_mutex_unlock() will now wake only one thread at a time.
Previously, it would wake all waiting threads (though that was
unnecessary, even with a 2-state lock).

This also affects the C11 mtx_* implementation, which uses mxr_mutex.

MG-361

Change-Id: I6397bc0b2d4fc6c153d5eb22238e02fc5c8b5d33


# f01aaa42 18-Jan-2017 George Kulakowski <kulakowski@google.com>

[musl] Reenable missing-field-initializers for clang

Change-Id: I375e3a15d156a5c8eb1de4af0e380133ec33595d


# 0221cbb4 05-Oct-2016 George Kulakowski <kulakowski@google.com>

[musl] Tweak some types used in futex operations

This means moving a few types and operations to stdatomic.h types.

Change-Id: Ied45a4c49628dbfee55e708d581443bedafec742


# 59530928 19-Sep-2016 George Kulakowski <kulakowski@google.com>

[musl][format] Clang format musl

Change-Id: I9d0d2d586a6587dbedda055a3b3664296c7eb89a


# a3d7e591 01-Sep-2016 Roland McGrath <mcgrathr@google.com>

[ulib][magenta][runtime][musl] Give system calls _mx_* names, use them in musl

The mx_* name space is not kosher for the standard C library to use
for its own purpose. A conforming standard C program can define its
own functions called mx_* and this must not break the C library.

Give all the system call entry points in the vDSO names starting
with _mx_, with the old mx_ names as aliases. Use only the _mx_
names in runtime and musl.

Change-Id: Id01b57b87c0bb91733e9492159401ff019943822


# f0b6c1a6 24-Aug-2016 George Kulakowski <kulakowski@google.com>

[musl][cnd_t] Fix cnd_timedwait

The original implementation of cnd_t relied on mtx_t having the same
layout as pthread_mutex_t. However, we have changed mtx_t to be
considerably smaller and simpler, based on mxr_mutex_t. Accordingly,
this patch essentially recreates the cnd_timedwait implementation, with
the internal locking changed. It is essentially the same as the
pthread_cond_timedwait implementation, with some dead code removed due
to the simpler mutex implementation.

Change-Id: If56f3be4547d16a567dfa9cda0954430c126a52c


# 53b9e1c8 15-Jun-2016 The Fuchsia Authors <authors@fuchsia.local>

[magenta] Initial commit