Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I find out the CPU core of a specific thread at runtime?

Tags:

c++

c

cpu-cores

cc

I am running CC compiler over SUN/Solaris.

I have more than 64 threads assigned by the OS to different cores. I am interested to know if there is any method to get the core id for different threads during runtime?

I am not setting affinity for those threads, I use psrset to create the processor set.

like image 756
Michael Avatar asked Jan 26 '26 01:01

Michael


1 Answers

I found the answer: getcpuid() on Solaris returns the core id (even for hyper thread): i have tested it and it works great. http://www.unix.com/man-page/all/3c/getcpuid/

like image 151
Michael Avatar answered Jan 27 '26 14:01

Michael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!