I am trying to track down some threads which are seeing high cpu use in top(1), but can't work out how to track back from any information available from struct kinfo_proc back to a thread ID as returned by pthread_self().
The threaded program can print a nice display of its own internal concept of "thread name", with the value returned by pthread_self(), and on some OS it also stores what I think is their equivalent of our p_tid, e.g. on linux it uses syscall(SYS_gettid). Do we have a way within a threaded program to determine the current thread's p_tid? Or is there a way to go from p_tid (or something else available in struct kinfo_proc) back to a thread ID returned by pthread_self()? Thanks.