Re: Time outs and state machines
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Feb 2006 10:57:19 +0100
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
.
- References:
- Time outs and state machines
- From: Leslie Sanford
- Time outs and state machines
- Prev by Date: Re: Time outs and state machines
- Next by Date: Re: OOP can be simply summed up as 'passing messages to objects'
- Previous by thread: Re: Time outs and state machines
- Next by thread: Re: Time outs and state machines
- Index(es):
Relevant Pages
|