The world's most popular open source database
#include <sys/types.h>#include <assert.h>#include <limits.h>#include <pthread.h>#include <stdio.h>#include <unistd.h>#include <signal.h>#include <sched.h>#include "linuxthreads.h"Include dependency graph for linuxthreads.c:

Go to the source code of this file.
Defines | |
| #define | AT_INT(intval) *((int32_t*)(intval)) |
Functions | |
| int | linuxthreads_notify_others (const int signotify) |
Variables | |
| volatile int | __pthread_threads_debug |
| volatile char | __pthread_handles |
| char | __pthread_initial_thread |
| const int | __pthread_sizeof_handle |
| const int | __pthread_offsetof_descr |
| const int | __pthread_offsetof_pid |
| volatile int | __pthread_handles_num |
| #define AT_INT | ( | intval | ) | *((int32_t*)(intval)) |
| int linuxthreads_notify_others | ( | const int | signotify | ) |
Definition at line 40 of file linuxthreads.c.
References __pthread_handles, __pthread_handles_num, __pthread_initial_thread, __pthread_offsetof_descr, __pthread_offsetof_pid, __pthread_sizeof_handle, assert, AT_INT, threads, and TRACE_FPRINTF.
Referenced by segv_action().
00041 { 00042 const pid_t mypid = getpid(); 00043 //const pthread_t mytid = pthread_self(); 00044 int i; 00045 int threadcount = 0; 00046 int threads[PTHREAD_THREADS_MAX]; 00047 int pid; 00048 00049 TRACE_FPRINTF((stderr, "theadcount:%d\n", __pthread_handles_num)); 00050 if (__pthread_handles_num==2) { 00051 /* no threads beside the initial thread */ 00052 return 0; 00053 } 00054 /*assert(maxthreads>=3); 00055 assert(maxthreads>=__pthread_handles_num+2);*/ 00056 00057 // take the initial thread with us 00058 pid = AT_INT(&__pthread_initial_thread + __pthread_offsetof_pid); 00059 if (pid!=mypid && pid!=0) 00060 threads[threadcount++] = pid; 00061 // don't know why, but always handles[0]==handles[1] 00062 for (i=1; i<__pthread_handles_num; ++i) { 00063 const int descr = AT_INT(&__pthread_handles+i*__pthread_sizeof_handle+__pthread_offsetof_descr); 00064 assert(descr!=0); 00065 pid = AT_INT(descr+__pthread_offsetof_pid); 00066 if (pid!=mypid && pid!=0) 00067 threads[threadcount++] = pid; 00068 } 00069 /* TRACE_FPRINTF((stderr, "Stopping threads...")); */ 00070 //for (i=0; i<threadcount; ++i) { 00071 // /* TRACE_FPRINTF((stderr, "%d ", threads[i])); */ 00072 // fflush(stdout); 00073 // kill(threads[i], SIGSTOP); /* Tell thread to stop */ 00074 //} 00075 /* TRACE_FPRINTF((stderr, " done!\n")); */ 00076 for (i=0; i<threadcount; ++i) { 00077 TRACE_FPRINTF((stderr, "--- NOTIFYING %d\n", threads[i])); 00078 kill(threads[i], signotify); /* Tell to print stack trace */ 00079 /* TRACE_FPRINTF((stderr, "--- WAITING FOR %d\n", threads[i])); */ 00080 /*pause(); Wait for confirmation. */ 00081 } 00082 for (i=0; i<threadcount; ++i) 00083 sched_yield(); 00084 for (i=0; i<threadcount; ++i) { 00085 TRACE_FPRINTF((stderr, "--- KILLING %d\n", threads[i])); 00086 kill(threads[i], SIGKILL); /* Tell thread die :) */ 00087 } 00088 return __pthread_handles_num; 00089 }
Here is the caller graph for this function:

| volatile char __pthread_handles |
Referenced by linuxthreads_notify_others().
| volatile int __pthread_handles_num |
Referenced by linuxthreads_notify_others().
Referenced by linuxthreads_notify_others().
| const int __pthread_offsetof_descr |
Referenced by linuxthreads_notify_others().
| const int __pthread_offsetof_pid |
Referenced by linuxthreads_notify_others().
| const int __pthread_sizeof_handle |
Referenced by linuxthreads_notify_others().
| volatile int __pthread_threads_debug |
1.4.7

