Using timeout triggers

Timeout triggers have the syntax tm(<expression>), where <expression> is the number of time units.

About this task

The default time unit is milliseconds. The time units are set based on the operating system adapter implementation of the tick timer. A timeout is scheduled when the origin state (s1) is entered. If the origin state has exited before the timeout was consumed, the timeout is canceled.

Timeout trigger

You can use the timeouts mechanism (tm()) when the quality of service (QOS) accuracy requirement conforms with the following timeout accuracy. When a timeout occurs, it is inserted to the event queue related to the reactive instance. The time on which the timeout is consumed depends on the actual system state. The timeout occurrence depends on three factors:

Procedure

  1. The timeout request time (T)
  2. The tick-timer resolution (R)

    The resolution specifies how often the system checks if there are expired timeouts.

  3. Timeout latency (L)

    The tick timer implementation for some operating system adapters is synchronous (using a call to sleep(interval)). This implementation means that there is a built-in latency (the time spent processing the expired timeouts). This latency can be significant when the timeout is long (involving multiple timer ticks).

    The following formula determines when a timeout expires:

          [(T+L)-R,(T+L)+R]
    Note: If you use triggered operations and events (including timeouts) in the same statechart and the triggered operation can be called from an object running in a thread other than the event consumption thread, it might lead to a race situation. To prevent the race, make the triggered operations guarded (which also prevents the race with timeouts).

Feedback