[SDL Forum Society - Logo] Tutorial on SDL-88
Belina, Hogrefe (edits Reed)

3.5 Timers

Back Home Up Next

In a system model there is often a need to define time constraints. SDL has the timer construct for this. The timer is an object, owned by a process, that is able to generate a signal with the same name and put this signal into the input queue of the process.

Figure 17: Description and use of timer
Note: Fragment of an SDL-88 process diagram.

A timer is defined in the process diagram, in a text symbol. Figure 17 shows an example. The text "TIMER T;" in the text symbol defines the timer T.

During a transition a timer can be activated with the SET construct in a task symbol (a rectangle). The set construct has two arguments. First one is the absolute time for the expiration of the timer, and the other one is the name of the timer. For the specification of the expiration time, the expression NOW (of the predefined type Time, which is similar to Real) can be used. NOW always gives the current time during the interpretation of the system description. For example T could be set to the value NOW+13 just before entering the state Wait, so that the process remains in Wait for 13 time units. 
Note: The unit of time is not defined in SDL-88, but usually taken as 1 second and in SDL-2000 is by default 1 second).

After time as advanced and reached the previously specified value, a timer signal with name T is put into the input queue of the process. The semantics of the input queue are described precisely in Process communication.

In the example of figure 17, the timer T is instead SET to the value expirytime + period. When the process starts (at the start symbol) expirytime is set to the absolute time 0.0 units. The variable period is a Duration value (similar to Real and used to represent the difference in two Time values) and is preset to 13 units. So just before each time the state Wait is entered, the timer T is set to precisely 13 units more than the previous occasion. The advantage of this approach (compared with NOW +13) is that the times for the timer to expire follow a strict period, and the time taken to handle the period action has no impact on these times, which are at the times 13, 26, 39 and so on. In addition, if occasionally it takes longer than 13 units to handle the action, the timer will expire as soon as it is SET. Therefore although some periodic actions may be delayed, provided the average handling period is less than 13 units, none will be missed and the periods will automatically resynchronise.

An activated timer can be deactivated with the RESET construct, which has a single parameter - the timer name. After resetting the timer, the process behaves in a way as if the timer has never been activated. If the timer signal is in the input queue, it is removed. When a timer is SET, it is equivalent to a RESET followed by a SET. Both SET and RESET have to be placed in a task symbol without any other action (such as an assignment).

The example in figure 17 also introduces a couple features not previously introduced: connectors and text extension. A connector symbol is a circle that has a connector name associated with it. Often the name is one or two characters such a A1, B1 and is written inside the symbol. In the example the names (PeriodicAction and Wait4Timer) are too large to fit inside the symbol and therefore are shown in a text extension symbol (rather than make the symbol larger). A text extension symbol can be added to any symbol to allow more text than will fit in the symbol. The text (if any) inside the symbol is taken first, followed by that in the text extension symbol.

A connector allows a process diagram to be split onto more than one page, as it connects flow from an out-connector (such as PeriodicAction in figure 17) with flow leading to it, to an in-connector (such as Wait4Timer  in figure 17) with flow leading from it. Connectors are also useful to avoid flow lines crossing on a single page of a diagram.

Back Home Up Next

Contact the webmaster with questions or comments about this web site.
Copyright 1997-May, 2013 SDL Forum Society