What all factors are important when measuring CPU time for a process?
I am not interested in How to measure CPU time
as it will largely depend on the Operating System. But I want to know if I have to measure the CPU time for a process what all different times should be summed up to report the total CPU time taken by a process which remain independent of OS.
I can imagine it will have to be a sum of actual CPU time taken in executing instructions ( User mode as well as Kernel mode) but also Context Switching time , I/O time etc. What all these factors are? A small explanation on each factor would also be very helpful. For example, when CPU switches from process p1 to p2, in which process bucket 'time taken to switch' is accounted for ?