Re: Time outs and state machines



On Mon, 27 Feb 2006 15:33:49 -0600, Leslie Sanford wrote:

There is a scenario that's probably rare but it's bothering me. Suppose
the receiving device sends an ACK message just before the timer elapsed
event. The ACK message gets put on the queue and immediately after the
timer event places its message on the queue as well. The state machine
consumes the ACK message. The next message in the queue is the timer
event. When the state machine consumes it, it believes that the 20
milliseconds for the last message have elapsed when in fact they have
not.

This is called race condition.

I'm not sure what I'm missing, but I'd like my code to me more robust
than this. Is there an additional state that would prevent the above
scenerio? I was thinking about giving each timer event a unique ID as
one approach. When the state machine consumes a timer event, the ID must
be valid for the next message or it is ignored.

You have to keep track on the states of the device you are talking with.
Usually when timeout or any other protocol error happens, the device [a
connection to is reset to bring all parties into a definite state. This
ensures that any belated ACK will be ignored, because a reset confirmation
will follow. Some well-designed protocols deal with send windows, frames
etc, allowing resynchronization without full connection reset. But the idea
is same: you have to know the state on the other side.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: How to Convert 8bit into 6bit AIS encapsulation?
    ... I would suggest the more optimal method would use a look-up table opposed ... The timer event is queued such that it can be delayed for a number ... event would be missed entirely (never enter the queue). ... A slower machine is going process data slower. ...
    (microsoft.public.vb.general.discussion)
  • Re: Timer not being time-true
    ... Windows works by sending message on a queue. ... pumps a message and executes it... ... >I have a form that requeries data every 20 seconds based on a timer event. ... > sometimes the requery intervals are longer than 20 secons - sometimes as ...
    (microsoft.public.access.formscoding)
  • Question about DoEvents
    ... it also has a method that adds an item to the queue ... sub additem ... and control is going to the timer event (If the timer event fires at ...
    (microsoft.public.vb.general.discussion)
  • Re: Question about DoEvents
    ... If the queue is processing, it will accept additional queue items, and will ... doevents in the addItem method, it made me think that the doevents fired ... just as the timer event was firing to check for additional items (which it ... I wonder if perhaps the doevents in the addToQueue sub in the server is ...
    (microsoft.public.vb.general.discussion)