How to know on which physical processor and on which physical core my code is running

前端 未结 5 1105
抹茶落季
抹茶落季 2020-12-01 22:06

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.

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 22:37

    By and large it's hard to find this out in a meaningful way. Your thread will often run on many different processors during its life. You could call a function to ask which processor you are on and get a context switch whilst the function is executing. What should the function return?

提交回复
热议问题