Re: Linux application level timers?

From: Chris Friesen (
Date: Thu Jan 23 2003 - 11:28:35 EST

Tom Sanders wrote:
> I'm writing an application server which receives
> requests from other applications. For each request
> received, I want to start a timer so that I can fail
> the application request if it could not be completed
> in max specified time.
> Which Linux timer facility can be used for this?

I used setitimer for a similar task. Since you can only have one timer
going at any given time, I set up a linked list of timing events, with
each event's timeout expressed as a delta from the previous event. This
way changing the time on the system has no effect on the application.
The itimer is then set for the first event in the list. When a timer
goes off, it optionally re-inserts the event into the list, starts the
next itimer, and then calls a callback function for the expired event
with an opaque data pointer as an argument.

Works really well.


Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email:

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to More majordomo info at Please read the FAQ at

This archive was generated by hypermail 2b29 : Thu Jan 23 2003 - 22:00:31 EST