Counting thread's context switches
Is it possible to count the context-switches for a thread? I'm tracing an application 'A' with ptrace(). Say 'A' has n threads. I want to know how may times each thread in 'A' faced a context-switch.
Do we have any mechanism that can notify the tracing process about context-switches in traced process?