public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Dake <sdake@mvista.com>
To: Tom Sanders <developer_linux@yahoo.com>, linux-kernel@vger.kernel.org
Subject: Re: Linux application level timers?
Date: Wed, 22 Jan 2003 16:03:44 -0700	[thread overview]
Message-ID: <3E2F2350.8050107@mvista.com> (raw)
In-Reply-To: <20030122221703.42913.qmail@web9806.mail.yahoo.com>

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.

Thanks
-steve

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,
>Tom
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
>http://mailplus.yahoo.com
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/
>
>
>
>  
>


  reply	other threads:[~2003-01-22 22:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-22 22:17 Linux application level timers? Tom Sanders
2003-01-22 23:03 ` Steven Dake [this message]
2003-01-22 23:35 ` george anzinger
2003-01-23  4:36 ` Gerhard Mack
2003-01-23  8:37 ` Narsimha Reddy CH
2003-01-23  8:51 ` Riku Meskanen
2003-01-23 16:28 ` Chris Friesen
2003-01-23 17:26   ` DervishD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E2F2350.8050107@mvista.com \
    --to=sdake@mvista.com \
    --cc=developer_linux@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox