What kind of context switch is counted in the cs parameter in the output of vmstat command

vmstat

vmstat provides a counter cs for context switch. As this explains, the context switch can be from one process to another , kernel to user or due to a interrupt being fired. Does the cs give a total of this?If so, is there a way I can get an individual output

Best Answer

Vmstat cs column is displaying, at least on Solaris, voluntary context switches, i.e. those happening when a process (thread really) is releasing the CPU because it has nothing else to do with it, for example waiting for some external event like a pending I/O to finish.

If you want to display involuntary context switches, you can use the mpstat command an look at its icsw column. Here are displayed context switches due to a process being interrupted/preempted because something with a bigger priority requires the CPU.

Related Topic