Frederick, I think the problem is in the handler. It reminds me of a discussion we have had earlier this year with Mark Krentel.
The problem is related to your assumption about which thread handles the signal for which context. You are assuming that each thread processes its own samples. There is no such guarantee with async signals. So I think the reason you program hangs sometimes is simply because you are not reading from the correct context. The only information that is trustworthy is the file descriptor carried by the siginfo (info->si_fd), assuming you've specified SA_SIGINFO in the sigaction structure.. You need to use info->si_fd to identify the context for which you have to process the signal. Using gettid(), or pthread_self() won't work. And yes, a thread may be used to process another thread's samples. Obviously, I don't have control over POSIX signal semantics and threads, so there is not much we can do about this. One thing I do recall, though, is that if you use a real-time signal instead (sig > 32) , then things improve. > void my_handler(int n, struct siginfo *info, struct sigcontext *sc) { > int tid = syscall(SYS_gettid); > int cpu = tid - getpid() - 1; > > printf("cpu: %i\n", cpu); > if (ibs_handle_samples(ctx_fd[cpu], &pd[cpu], buffer[cpu]) != IBS_SUCCESS) > exit(-1); > } ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ perfmon2-devel mailing list perfmon2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perfmon2-devel