Find the answer to your Linux question:
Results 1 to 2 of 2
I have basically 2 questions which is mentioned below 1. how to pass arguments to a Timer. When we create a timer , we tie it up to a function ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4

    doubt about POSIX Timers

    I have basically 2 questions which is mentioned below

    1. how to pass arguments to a Timer. When we create a timer , we tie it up to a function , but When the timer expires i need some arguments to be passed to the function. for example. if the function which timer is calling needs the value of the connection id how do i pass it by timer ?

    2. this is more of a design issue which I feel many of the guys here must have faced it at some point. For a particular implementation a process needs to send a UDP packet if a client doesn't send at the appropriate times. Since there were multiple clients i thought of associating each client with a timer and one process which takes in charge of creating, resetting them . Is this an OK design or is there any flaws ?

    waiting for a reply..
    titus

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    What may be the "best" design for something like this is a matter of resources. If you have hundreds of connections, then having a timer associated with each connection is probably not a good idea, but would be better off with a single timer that is set to expire when the next connection needs to be services, keeping information about the time to expire for each connection in some data structure that is updated each time the timer expires. If you only have a few connections, then having a timer for each is not a bad idea and requires less complex programming than the other method.

    Anyway, please show the posix timer functions you are using, and how you are using them.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...