How to know on which physical processor and on which physical core my code is running
How can I know in a C program, on which physical processor and core my code is running? I'm using Linux and gcc 4.4.3. You may check /proc//stat file system, according to http://www.kernel.org/doc/Documentation/filesystems/proc.txt , you should just check task_cpu flag. As example without correct types and error checking: struct pstat { int pid; //process id char tcomm[256];//filename of the executable char state[2]; //state (R is running, S is sleeping, D is sleeping in an //uninterruptible wait, Z is zombie, T is traced or stopped) int ppid;// process id of the parent process int pgrp;//