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. 回答1: 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 /