I'm looking for a way to create a high performance counter. I've tried about using hash_set, hash number comes from pthread_self(), but pthread_self() is not the corrent thread id (it is memory address). and gettid() is not a standard syscall.
Is there a way to know the current thread is running on which CPU ? So that, I can create a per cpu counter, and sum them up to get count in high speed.