This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

On 07/13/2018 02:59 PM, Adhemerval Zanella wrote:

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).

That's not true. The POSIX thread ID is available using pthread_self on the thread itself, and that can be passed to another thread.

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.

From my point of view, the least surprising approach would be to make thrd_sleep a cancellation point to match nanosleep.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]