I trying to debug a Pthread enabled program under Linux or FreeBSD. Thereby I require the id's (in terms of pthread_t
thread identifiers) of all threads running in the program. For example as an array of pthread_t
. But I am not able to modify the thread's function because on the one hand I do not have access to the source code of some libraries and on the other hand parts of the parallel code are implemented using OpenMP and there is no thread-function which I can modify.
Is there a portable way, to obtain the number of currently existing pthreads of a program and their pthread_t
identifiers? The final thing I have to realize looks like
int n = get_number_of_threads();
pthread_t *threads = get_thread_list();
for ( i = 0; i < n; i++) {
pthread_kill(threads[i], SIGUSR1);
}