I am about to find out how a specific process, in C, loads the CPU over a certain time frame. The process may switch processor core during runtime, therefore I need to handle that too. The CPU is an ARM processor.
I have looked at different ways to get the load, from standard top, perf and also to calculate the load through the statistics given in the /proc/[pid]/stat-file.
My thoughts is to have a program that read the /proc/[pid]/stat-file as suggested in the thread: "How to calculate the CPU usage of a process by PID in Linux from C?" and calculate the load accordingly. But how would I treat core switching? I need to notice it and adjust the load calculation.
How would you recommend me to achieve this?
Update: How can I see which core the process runs in and by that examine if it has switched core since the last chack assuming I poll the process figures/statistics at least twice?