From here, How to see how many context switches a process makes? I found the method to view the number of context switching of alive process. But I need to view the whole number of context switching from the time when it is created to the time when it is dead. But after it deads, there is no proc filesystem. Is it any method to do it? Thanks for help
Asked
Active
Viewed 104 times
0
-
Do you mean context switching for entire OS? – Romeo Ninov Jul 13 '21 at 14:14
-
No, I mean one process – laurent01 Jul 13 '21 at 14:16
-
Can you clarify what do you mean by context switching after process dead. AFAIK if the process is dead there is no context switching for it – Romeo Ninov Jul 13 '21 at 14:17
-
Sorry for poor english. I mean the number of context switch when it was alive. In other words, I need to count the number of it from time when it is created to time when it is dead – laurent01 Jul 13 '21 at 14:19
-
The other answers to the question you've linked to explain how to start a process in a way that counts the context switches. Is that not what you look for? – Marcus Müller Dec 03 '21 at 16:57
1 Answers
1
On Linux, when a process dies, the kernel forgets most of the information about it, including context switches, and there’s no way to retrieve this information once it is gone. (Once a process is reaped, everything about it is forgotten.)
You need to instrument the processes you’re interested in ahead of time, using one of the approaches described in the question you linked to.
Stephen Kitt
- 411,918
- 54
- 1,065
- 1,164