Skip site navigation (1)Skip section navigation (2)
Date:      08 Nov 1998 16:29:39 -0600
From:      Joel Ray Holveck <joelh@gnu.org>
To:        fbsd@trifork.gu.net
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Semi-realtime programming Q (RS-232, timers)
Message-ID:  <86iugpx1gs.fsf@detlev.UUCP>
In-Reply-To: Andrew Stesin's message of "Sun, 8 Nov 1998 23:25:57 %2B0200 (EET)"
References:  <Pine.BSF.4.05.9811082307300.11274-100000@trifork.gu.net>

next in thread | previous in thread | raw e-mail | index | archive | help
[removed from -chat, still on -hackers]

> What I need is to implement multiple timers for protocl FSM
> to react onto, first for inter-character timeout on input, second
> one for write timeout, and several more "global" ones like
> the "link idle" timeout etc.

If several timers may come and go, then I would recommend just making
yourself a lowest-first priority queue of the alarm time_t's coupled
with the timers' handlers.  Set up a global SIGALRM handler to call
the handlers for the timers in the queue which have expired, and set
the next SIGALRM when the next timer is due.

If you only have a small set number of timers and want to save
yourself writing a priority queue, then your global SIGALRM handler
can check each one individually and set a SIGALRM to handle the next
one instead of messing about with a queue.

Either way, be sure to save the time_t when it hits, and use it to
check and reset all timers.  Otherwise, you end up possibly missing
one if some time elapses between when several time_t checks.

Happy hacking,
joelh

-- 
Joel Ray Holveck - joelh@gnu.org
   Fourth law of programming:
   Anything that can go wrong wi
sendmail: segmentation violation - core dumped

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86iugpx1gs.fsf>