Thread: Multi-thread server

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    7

    Multi-thread server

    Hey there everyone,

    I am currently working on a server program. Opens a port..listens for any requests from the client and then I have my N number of Threads pick up the tasks as they come in. I have implemented different policies for how the requests are handles(FIFO, SFF, etc) Now I want to get statistics about how my server does the work. Specifically,

    I want to keep statistics on individual threads as they do work.

    1. Count how many times the specific thread did a task
    example:

    2 threads
    8 requests
    how many times did thread 1 do work and how many times did thread 2 do work.

    2. Count how many times the specific thread handled a "static" request.
    3. Count how many times the specific thread handled a "dynamic" request.

    I have created a structure with many attributes on the request itself, but I can't seem to figure out how to keep a counter going unless I can some how keep track on each thread structure, but I don't know how to go about doing that. Any help is appreciated thank you!

    Is this a good enough explanation?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Are you wanting your overall "main" thread to keep these stats? For instance, you kick off your main thread, and a request comes in. You create your first "worker" thread and hand that request to it. Another new request comes in, and you create worker-thread #2 and pass that request.

    If so, when each worker thread ends, (or goes back to the thread pool for later reuse), you could have it update the main task's control structure, allocated to it, for keeping stats.

    Make sense?
    Mainframe assembler programmer by trade. C coder when I can.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi Thread Program Problem
    By ZNez in forum C Programming
    Replies: 1
    Last Post: 01-03-2009, 11:10 AM
  2. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 05:14 AM
  3. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  4. Win32 Thread Object Model Revisted
    By Codeplug in forum Windows Programming
    Replies: 5
    Last Post: 12-15-2004, 08:50 AM
  5. socket question
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 01:54 PM