-
Notifications
You must be signed in to change notification settings - Fork 77
Thread names
Alexander Saprykin edited this page Sep 8, 2023
·
2 revisions
Some operating systems provide an opportunity to set thread names. This feature is mostly used for debugging purposes and not as a normal thread attribute. Hence, some systems put various limitations (i.e. maximum name length, only method to set the name, etc.). The library supports thread names whenever it is possible, but due to limitations there is no guarantee that it will work under all systems and versions. Below is a list of supported systems with current limitations:
-
Linux: Since glib 2.12 supports pthread_setname_np() with up to 16 chars, otherwise provides
prctl()
withPR_SET_NAME
since kernel version 2.6.9. -
macOS: Since 10.6 uses
pthread_setname_np()
. -
Windows: Since version 10 (build 1607) supports
SetThreadDescription()
, otherwise tries to raise a special exception if supported by a compiler. -
FreeBSD: Since version 5.1 supports
pthread_set_name_np()
. -
OpenBSD: Since version 2.7 supports
pthread_set_name_np()
. -
NetBSD: Since version 5.0 supports
pthread_getname_np()
, limited toPTHREAD_MAX_NAMELEN_NP
chars. -
DragonFlyBSD: Since version 4.4 supports
pthread_set_name_np()
, limited to 16 chars. -
Solaris: Since version 11.3 supports
pthread_setname_np()
, limited to 31 chars. -
QNX: Since version 6.3.2 supports
pthread_setname_np()
, limited to_NTO_THREAD_NAME_MAX
chars. -
Tru64: Since (at least) version 4.0G supports
pthread_setname_np()
, limited to 31 chars. -
OpenVMS: Since (at least) version 7.2 supports
pthread_setname_np()
, limited to 31 chars. -
BeOS: Supports
rename_thread()
, limited toB_OS_NAME_LENGTH
chars. - Haiku: The same as for BeOS.
-
Syllable: Supports
rename_thread()
, limited toOS_NAME_LENGTH
chars. -
AmigaOS: Supports
task->tc_Node.ln_Name
field in the task structure. -
Android: Since API level 26 supports
pthread_setname_np()
, limited to 16 chars. -
iOS: Since version 3.2 supports
pthread_setname_np()
. - BlackBerry 10: The same as for QNX.
The rest of operating systems do not support thread names.