Context-switching - vmstat

  1. The problem statement, all variables and given/known data:

[LEFT]Type `vmstat -s; vmstat -n 1 5; vmstat -n 1 5; vmstat
-s` to your Ruby interpreter. Then terminate your Ruby session. Run the Unix com-
mand vmstat -s; vmstat -n 1 5; vmstat -s in the same terminal window you had
been using for Ruby. Did the context-switching rate of your system change signi cantly,[/LEFT]
after the Ruby interpreter was shut down? Explain briey.

  1. Relevant commands, code, scripts, algorithms:

  2. The attempts at a solution (include all code and scripts):

So what i did is:
After typing this command "vmstat -s; vmstat -n 15; vmstat -n 15; vmstat -s"

I found 2 context switches. The one is 707227535 and the other one is 707222952. I substracted them and divided by 10 as the "vmstat -n 1 5" five times in duration of one second per line. Because it does this 2 times than my calculation looks like that:

context switches per second = (707227535-707222952)/(2x5)=458

After terminating Ruby interpreter i typed: "vmstat -s; vmstat -n 1 5; vmstat -s"

and the calculation goes like that:

context switches per second = (707306157-707303877)/5=456

The questions are:

  1. Am i doing the right calculations for context switches?
  2. What does it mean that the resolt in both cases is so close to each other?

Thank you with advance.

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

University of Auckland
Auckland City
New Zealand
Clark Thomborson

I believe that you are doing the correct calculations, though the sample time is much too short to be meaningful.

As long as you are the sole user of the computer on which you ran "vmstat" we could deduce that your Ruby session was not a major hit on that particular system resource. So what?

Personally I could not deduce anything significant from these statistics with such a small sample.

Now, if you ran a process for an hour and could see a distinct change in context switches that might be worth investigating.

Other posters may wish to comment.

Thank you methyl. I'm very appreciate for your help. It obviously make sense and thats exactly what i was thinking.