Normally, the OS distributes threads to the different CPUs, so any CPU that it's running on right now may or may not be the same CPU it's running on in a millisecond. However, you can control thread affinity with POSIX threads, which Linux supports, or you can use e.g. a tool like htop to assign threads/processes to CPUs.
- Ulrich Eckhardt
@SergeiKulik pthread_getaffinity_np() is always returning 0, even though I am setting affinity using pthread_setaffinity_np().
- Barinder Grewal
What does the manpage have to say about that particular returnvalue?
- Ulrich Eckhardt
1 Answers
1
votes
I found the answer about how to check it using terminal.
/home# for i in $(pgrep applicationName); do ps -mo pid,tid,fname,user,psr -p $i;done
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
pthread_getaffinity_np()? man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html - Sergei Kulikhtopto assign threads/processes to CPUs. - Ulrich Eckhardt