[lkml]   [2003]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Linux application level timers?
Try select().

Depending on your architecture (ie: if requests come in via TCP file
descriptors) you can use select. Select takes as an argument a timeout
value. You can calculate the minimum timeout value for a set of
timeouts by finding the minimum, and use that as your select timeout.
Before each time you call select, you can figure out all the timeout
values to find the minimum select period. This way you can control what
you do when with the timeout. After the select, you can then calculate
which timeouts have occured and act on them appropriately.

I use this for example to detect when a function should be polled while
also waiting on event-driven i/o from a tcp socket. I also use this to
detect when a heartbeat message should have been received but was not in
the alloted time, causing the socket to close and reconnect.


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 have checked out alarm() and signal() system calls,
>but these calls doesn't take an argument, so its not
>possible to associate application request with the
>matured alarm.
>Any inputs?
>Thanks in advance,
>Do you Yahoo!?
>Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
>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

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

 \ /
  Last update: 2005-03-22 13:32    [W:0.057 / U:5.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site