Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Context Switching

Status
Not open for further replies.

rhymejerky

Programmer
Nov 30, 2004
23
US
Hi,

When I do vmstat, 1 of the values return is the context switch in the current system. What is the significant of this value? I understand what context switching is, but don't understand what is the use of it. Does a higher number means the system is more utilized? How does it related to the characteristic of the threads running? Another one is iostat. This returns the I/O bandwidth utilization, does this number means the amount of utilization of a I/O device, say a HDD? Hope someone can give me a pointer to clarify this. Thanx!!!
 
Although vmstat is a "unix" command, there are slight differences in what is output depending on what system it is run. Please say what hardware and Operating System you are using.

Thanks.

Mike
 
I have Solaris 2.6 and Solaris 8. The hardware are mostly Sun Ultra 5. I undestand a context switch could mean switching between threads, updateing program counter etc, but don't really understand what this number is indicating in terms of system performance. Is a high number means the system is very busy? Just trying to understand this term and usage better. Thanks
 
A high number of context switches simply means the OS is switching between two or more processes. Whether that's good or bad depends on many other factors.

The laptop I'm typing on is doing about 250 cs/sec, my fileserver upstairs is doing over 1000 and my web server is hovering around 400. None of these machines are having a problem. Probably far more important to look at would be wait states, system load and swapping.
 
So, lets say a system has 1000 cs/sec. For certain time of the day, it jumps to 5000 cs/sec. Does this means the CPU usage is higher because more work is being done? What if the CPU idle reamins at 5% most of the time for this system. I am trying to understand what a sudden increase in cs that last for almost an hour mean. Thanks a lot
 
More context switches doesn't mean more work is being done. Any time the CPU switches from one task or thread to another, that is a context switch. It's just like channel surfing, you're not necessarily watching more TV, your just switching between shows. I *really* wouldn't worry about context switches, even when examining a horribly overloaded machine I never look at context switches, system load, IO wait, free memory and page faults are *way* more important.
 
That should read:

when examining a horribly overloaded machine I never look at context switches; system load, IO wait, free memory and page faults are *way* more important.
 
A significant increase in context switches, such as when cs is a lot higher than disk I/O and network packet rate, should be cause for investigation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top