[PATCH 1/3] Linux: Add the pthread_gettid_np function
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Mar 11 15:29:18 GMT 2025
On 11/03/25 11:15, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
>
>> So the question is whether we implement something similar to bionic,
>> and take the dl_stack_cache_lock to check if the pthread_t is
>> within dl_stack_cache/dl_stack_user. This will make the implementation
>> no async-signal-safe, but at least it would remove the potential UB.
>> We don't do this for other pthread functions, like pthread_join, but
>> if the idea is to use pthread_gettid to query the pthread_t lifetime
>> it would make sense to follow bionic here.
>
> No, I'm not proposing this function for this purpose. It's really there
> to better support the TID argumnt for sched_setattr and similar
> functions. (See the third patch in the series for examples.)
>
> Otherwise we would have to add pthread analogues for all
> these, and that seems excessive. Conceptually, these functions can only
> work with 1:1 thread model because we couldn't context-switch scheduler
> policies in an n:m model.
The problem is bionic already set a precedent and I am not feeling comfortable
on providing a non-portable symbol with same name with slight different semantic.
This might cause more confusion once it is mode wildly used, specially because
android is a Linux based system.
More information about the Libc-alpha
mailing list