Thread: Monitoring thread performance

  1. #1
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659

    Monitoring thread performance

    I'm trying to profile a system with a number of threads.

    If I look at the process/threads using process explorer (from sysinternals), I can see a thread context switch rate, and a total number of context switches.

    Finding the switch rate through WMI seems easy enough.
    But the total number of context switches - mmm, tricky.

    Several hours with the Thread API on MSDN didn't help, except to suggest some deprecated API, and that didn't go into enough detail to help either.

    I figured the information was easy enough to collect, and there must be some way to get at it since PE does.

    Thanks for any insight,
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    This is a site dedicated to hidden API functions and/or functions that are not in the SDK docs.

    http://undocumented.ntinternals.net/

    Hope it helps.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    Quote Originally Posted by Bubba View Post
    This is a site dedicated to hidden API functions and/or functions that are not in the SDK docs.

    http://undocumented.ntinternals.net/

    Hope it helps.
    There is nothing undocumented.
    It's a (sadly well-known...) poor site.
    Just read Wine or ReactOS source, and you'll get 10 x more apis.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I've used that site to call functions that were not in the SDK docs and they worked fine. Granted I would not rely on them since they are not officially supported and could change at any time.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Possibly use the PDH library to create a performance counter for acquiring the number of system/context switches or thread/context switches??????

    EDIT: Maybe this link can be of some help to you. Especially, the source code example.
    Last edited by BobS0327; 08-03-2008 at 06:51 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  2. thread termination
    By arjunajay in forum Windows Programming
    Replies: 3
    Last Post: 06-26-2006, 11:32 PM
  3. CreateThread ?!
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-15-2005, 10:55 AM
  4. pointer to main thread from worker thread?
    By draegon in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 06:35 AM
  5. Critical Sections, destroying
    By Hunter2 in forum Windows Programming
    Replies: 4
    Last Post: 09-02-2003, 10:36 PM