0

This question already has an answer here:

Is there any Linux command to get various information like context switches of a process? Any solution other than ps will be appreciated.

marked as duplicate by don_crissti, Stéphane Chazelas linux Feb 21 '17 at 21:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

A context switch counters are in /proc/$$/status:

As an example:

voluntary_ctxt_switches: 230 nonvoluntary_ctxt_switches: 35

You can get this easily by doing something similar to:

$ grep ctxt /proc/1234/status

  • Interesting. I tried on few pid but they have no ctxt value. Will try on more pid. There is another command (#command pid) which shows useful information (context switch is one of them) just like the stat (#stat filename) command. It was a very nice utility which i forgot :( – al mamun Feb 21 '17 at 21:20
  • If you want rolling stats, look at pidstat -w 1 – Ed Neville May 20 '18 at 6:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.