Review use of pthread_setname_np on Darwin
While reading through some RTS code, I noticed two places where pthread_setname_np
and similar functions are used to set the name of a thread that was created right before (rts/posix/OSThreads.c
and rts/posix/ticker/Pthread.c
).
It struck me how, in case the Darwin version of pthread_setname_np
is used (based on preprocessor tests), no identifier of the thread to be named is passed, unlike with other functions/platforms. Looking at the documentation, it looks like this call sets the name of the current thread, instead of some thread that was just created, which makes sense given the function signature.
Hence, could it be that thread naming is different on Darwin (and not as intended) vs. other platforms, i.e., instead of renaming the new/target thread, the current one is renamed? I don't have an OSX machine available to test...
Looks like this was introduced in bfe8ef8e.