LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-08-2008, 07:13 AM   #1
linuxdoniv
Member
 
Registered: Mar 2008
Posts: 63

Rep: Reputation: 15
Number of context switches


Hi,

I just found out the number of context switches a process( browser) undergoes using the field task->nvcsw and its interesting to see the following numbers,

1277,1277,1535,4087,9981,9981,9981,9975,9973,10229, 10231,10231,10229,9561,9469,10229,11509,11775....

Could anybody guide me why there is a variation in the numbers. I was expecting a monotonically increasing sequence for the number of context switches.
 
Old 05-08-2008, 07:50 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
The CPU scheduler in the OS kernel is responsible for switching tasks. It probably thinks other processes would like to use the CPU besides just your process, after having given it a bit more to see if it was temporary process (doing its job and exiting fast). It could also be for any number of reasons, all very hard to know because Linux has undergone a fairly dramatic CPU scheduler change, and while the CPU scheduler is always being fiddled with, its hard to really know what its doing without knowing the exact versions, patches applied, etc. So, the only way to really know, is to read the source code, or perhaps just the documentation relevant to the CPU scheduler.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
relationship between number of involuntary switches and prioirty linuxdoniv Programming 1 04-16-2008 09:26 AM
Context switches balteo Linux - General 0 09-06-2005 07:09 AM
What are the drawbacks of syscalls and context switches? shy Programming 7 11-25-2004 02:03 PM
how do you edit your virtual console number? (or VT number 3) jjorloff1 Linux - General 2 04-03-2004 07:21 PM
why there is a need for minor number and major number for monitor/keyboard in pc? tripathi Solaris / OpenSolaris 1 11-07-2003 09:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration