Issue 302 in psutil: Process number of context switches

13 views
Skip to first unread message

psu...@googlecode.com

unread,
Jul 11, 2012, 11:10:48 AM7/11/12
to psu...@googlegroups.com
Status: New
Owner: ----
CC: psu...@googlegroups.com
Labels: Type-Enhancement Priority-Medium Milestone-1.0.0

New issue 302 by g.rodola: Process number of context switches
http://code.google.com/p/psutil/issues/detail?id=302

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.



--
You received this message because you were CC'd on the issue.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

Reply to this email to add a comment.

psu...@googlecode.com

unread,
Jul 12, 2012, 1:03:29 PM7/12/12
to psu...@googlegroups.com
Updates:
Status: FixedInSVN

Comment #1 on issue 302 by g.rodola: Process number of context switches
http://code.google.com/p/psutil/issues/detail?id=302

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

psu...@googlecode.com

unread,
Mar 1, 2013, 5:37:17 PM3/1/13
to psu...@googlegroups.com

Comment #3 on issue 302 by g.rodola: Process number of context switches
http://code.google.com/p/psutil/issues/detail?id=302

Updated csets after the SVN -> Mercurial migration:
r1438 == revision 612dd9ff0999
Reply all
Reply to author
Forward
0 new messages