This is the mail archive of the libc-alpha@sourceware.org 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 2/8] nptl: Add C11 threads mtx_* functions



On 12/07/2018 15:39, Florian Weimer wrote:
> On 07/10/2018 02:35 PM, Adhemerval Zanella wrote:
>>
>>
>> On 06/07/2018 09:51, Florian Weimer wrote:
>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>> This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011),
>>>> more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock,
>>>> mtx_unlock, and required types.
>>>>
>>>> Mostly of the definitions are composed based on POSIX conterparts, and mtx_t
>>>> is also based on internal pthread fields, but with a distinct internal layout
>>>> to avoid possible issues with code interchange (such as trying to pass POSIX
>>>> structure on C11 functions and to avoid inclusion of pthread.h).  The idea
>>>> is to make possible to share POSIX internal implementations for mostly of
>>>> the code (and making adjustment only when required).
>>>
>>> Should we check for the supported mutex types and error out if the type does not match?  The interface does not support the full range of error codes required by robust mutexes, for example—EOWNERDEAD is missing.
>>>
>>
>> I am not sure if adding extra tests will yield any gain, specially on mutex
>> operations which users would expect optimized fast paths.  I really think
>> we should handle as undefined behaviour if uses try to use pthread_t objects
>> with c11 threads function (in similar manner it is undefined behaviour if
>> uses messes with internal pthread_mutex_t objects data directly).
> 
> Some people might be tempted to use the C11 interfaces to avoid the (formal) namespace violations of the POSIX functions, but still stick to the underlying POSIX objects for type compatibility on other interfaces.
> 
> But I think we can clearly document that they shouldn't do this.

Even if developers try to do this, it will be implementation specific
(in a sense an implementation may provide different underlying types
for POSIX and C11 thread objects). I really think we should explicit
this is a non-supported scenario.

> 
> I'm concerned about this because in the future, we might compile the implementations to remove checks that are not needed for the C11 implementations.

Why kind of scenario do you have in mind? Maybe use a more streamlined
internal implementation for C11 threads?
 


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