Blog

Posted 2011/07/01

Finding what core a thread is executing on

One of our research projects is improving thread scheduling on Linux. For some of our experiments we need to be able to know where a thread is executing without settings its affinity. With a bit of help from a Linux geek I know (after Google failed us) we found a function that works.

sched_getcpu - determine CPU on which the calling thread is running

You can read the documentation for it here:
http://www.kernel.org/doc/man-pages/online/pages/man3/sched_getcpu.3.html