During a performance investigation, you run vmstat 1 on a production server and notice the cs column averaging about 40 000 context switches per second-far above the normal baseline. CPU use is only moderate and %wa is near zero, so you suspect a single application is thrashing the scheduler. You need a live, per-process view of both voluntary and involuntary context switch rates to track down the culprit. Which command will give you that information most directly?
The pidstat -w option from the sysstat suite reports task-switching activity for each running process (and its threads) in real time. Its cswch/s and nvcswch/s columns show voluntary and involuntary context switches per second, allowing you to see exactly which PID is generating excessive switches.
sar -w can show system-wide context-switch counts but not a per-process breakdown, so it will not identify the individual offender. mpstat -P ALL focuses on per-CPU utilisation and does not display context-switch data. iostat -xz reports storage I/O latency and throughput, not scheduler activity. Therefore, only the pidstat command meets the stated requirement.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a context switch in Linux?
Open an interactive chat with Bash
What is the difference between voluntary and involuntary context switches?
Open an interactive chat with Bash
Why is `pidstat` more useful than `sar` for identifying context switch issues?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Troubleshooting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access