[PATCH v8 1/8] nptl: Add C11 threads thrd_* functions

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Jul 13 12:59:00 GMT 2018



On 13/07/2018 06:45, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>    2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
>>       errno, to handle expected standard return codes, and to avoid making
>>       the call a POSIX cancellation entrypoint.
> 
> Isn't this inconsistent with the conditional variable wait and thread join functions, which are still cancellation points?
> 
> On the other hand, a sleep function which is not a cancellation point may be useful.

I am not sure which would be the best option to handle POSIX cancellation
with C11 threads with nptl implementation. Most straightforward option is
just use cancellation entrypoints as default, even though using thread
cancellation in C11 is UB (there is no defined way the use can get the
POSIX thread id from a C11 thread). This don't require much internal
code change

Another option is just disable cancellation by using non-cancellable
entry-points and/or explicit disable cancellation.  For thrd_join is
just a matter to set on '__pthread_timedjoin_ex', but for 
cnd_wait/cnd_timedwait we either need to explicit enable/disable or 
add an option to __pthread_cond_wait_common to select whether to use
cancellable syscalls.



More information about the Libc-alpha mailing list