A Question About NPTL in glibc

Basile Starynkevitch basile@starynkevitch.net
Wed Nov 12 08:16:54 GMT 2025


On Wed, 2025-11-12 at 15:52 +0800, panzhe0328 wrote:
> ---
> Dear:
> 
> I wonder if I might inquire: Can the NPTL module in glibc ensure that multiple threads do not use the same thread stack simultaneously?

No, but your C or C++ code could.

See 

https://man7.org/linux/man-pages/man3/pthread_create.3.html
https://man7.org/linux/man-pages/man2/clone.2.html
https://man7.org/linux/man-pages/man3/pthread_attr_setstack.3.html
https://man7.org/linux/man-pages/man2/mmap.2.html
https://man7.org/linux/man-pages/man2/madvise.2.html


by the way, you could patch the glibc (it is tricky) or study its source code, or those of  https://musl.libc.org/
(and perhaps choose to use MUSL instead of GNU libc)

Regards from near Paris in France
-- 

Basile STARYNKEVITCH                    basile AT starynkevitch DOT net
8 rue de la Faïencerie                       http://starynkevitch.net/Basile/  
92340 Bourg-la-Reine                         https://github.com/bstarynk
France                                https://github.com/RefPerSys/RefPerSys
                  https://orcid.org/0000-0003-0908-5250


More information about the Libc-help mailing list