Events often need to be synchronized and propagated. However, Modelica gives no guarantee that two different independent events occur at exactly the same time instant if they are not explicitly synchronized, e.g. via equations.

To achieve guaranteed synchronization between two events, we use the synchronous principle that computation at an event takes no time. An event can instantaneously, via one or more equations, change the values of certain discrete time variables used for the synchronization, typically Boolean or Integer variables. These changes may trigger other events without any elapsed time, which thereby are synchronized. For example, you can synchronize counters performing their counting behavior at different frequencies, e.g. as in the example below.

Below is a version of the previous model using clocked synchronous language primitives. The new model called SynchCountersClocked has a structure that is very similar to the previous model. The unclocked when-equations have been replaced by clocked when-equations. The pre() calls in the difference equations have been replaced by calls to previous(). The slowPulses and fastPulses variables have been changed from Boolean to the built-in Clock type. The clock constructor call Clock(1) now returns a clock with interval 1 second used for fastPulses. For slowPulses we use the built-in subSample() operator to obtain every second clock tick giving an interval of 2 seconds. Finally, we have introduced two unclocked hold variables hcount and hslowCount which are defined also between clock ticks, whereas the clocked variables count and slowCount are only defined at clock ticks.

This model contains clocked synchronous constructs that are not yet supported by OpenModelica as of October 2015, but may start working within the near future. Hence Simulation of this model does not work

There is an alternative way of writing this model without clocked when-equations if we make the difference equations clocked by other means, as shown in the shorter model SynchCounters-ClockedShort below

This model contains clocked synchronous constructs that are not yet fully supported by OpenModelica as of October 2015, but may start working within the near future. Hence Simulation of this model does not work

A kind of "deadlock" between different when-equations is present if there are mutual dependences, a so-called "algebraic loop", between the equations of the when-equations, as in the example below. This case should be detected by a Modelica compiler.