[PATCH 1/3] Linux: Add the pthread_gettid_np function
Florian Weimer
fweimer@redhat.com
Tue Mar 11 14:15:20 GMT 2025
* 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.
Thanks,
Florian
More information about the Libc-alpha
mailing list