3

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); 
}
M.K. aka Grisu
  • 2,338
  • 5
  • 17
  • 32
  • No. https://stackoverflow.com/questions/3475750/posix-api-call-to-list-all-the-pthreads-running-in-a-process – Erik Alapää Nov 09 '17 at 16:41
  • Possible duplicate of [POSIX API call to list all the pthreads running in a process](https://stackoverflow.com/questions/3475750/posix-api-call-to-list-all-the-pthreads-running-in-a-process) – Raedwald Jun 05 '18 at 16:09

0 Answers0