Multi-thread server

This is a discussion on Multi-thread server within the C Programming forums, part of the General Programming Boards category; Hey there everyone, I am currently working on a server program. Opens a port..listens for any requests from the client ...

  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
    Katy, Texas
    Posts
    2,309
    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?
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

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, 10:10 AM
  2. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 04: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, 07:50 AM
  5. socket question
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 01:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21