Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process number of context switches #302

Closed
giampaolo opened this issue May 23, 2014 · 3 comments
Closed

Process number of context switches #302

giampaolo opened this issue May 23, 2014 · 3 comments

Comments

@giampaolo
Copy link
Owner

From g.rodola on July 11, 2012 17:10:37

Proposal  
Add the possibility to determine the number of context switches executed by a 
given process: http://www.linfo.org/context_switch.html 
http://en.wikipedia.org/wiki/Context_switch What a user might typically want to 
do with them is to monitor a process and figure out the increase rate of ctx 
switches every second. 

On what platforms would this be available?  
All 

Proposed API  
>>> p = psutil.Process(pid)
>>> p.get_num_ctx_switches()
ctxs(voluntary=9123, involuntary=1238)
>>>

The voluntary/involuntary distinction should exist in the UNIX world only.
On Windows we can fill 'voluntary' and leave 'involuntary' to 0. 

Are there existent implementations we can use as an example?  
On Windows this can be determined by using SYSTEM_PROCESS_INFORMATION struct: 
http://alax.info/blog/1182 On Linux we read /prof as always.
Still haven't looked into BSD/OSX but it's very likely they are exposed.

Original issue: http://code.google.com/p/psutil/issues/detail?id=302

@giampaolo
Copy link
Owner Author

From g.rodola on July 12, 2012 10:03:20

Fixed in r1438 (Linux), r1439 (BSD), r1440 (OSX), r1441 (Windows).
'involuntary' field is set to 0 on OSX and Windows.

Status: FixedInSVN

@giampaolo
Copy link
Owner Author

From g.rodola on August 13, 2012 09:25:13

Fixed in version 0.6.0, released just now.

Status: Fixed
Labels: -Milestone-1.0.0 Milestone-0.6.0

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 04:10:46

Updated csets after the SVN -> Mercurial migration: r1438 == revision 
baacf9660220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant