Designing the communication and synchronization between components of a distributed
system is often a non-trivial task. To avoid flaws, it is worthwhile to use mathematical
models capable of making appropriate validation possible. Petri net and it’s extensions are
such mathematical modeling languages.
Unfortunately, developers tend to make changes that diverge from the original model du-
ring the development due to changes in the specification. That means the implementation
is not guaranteed to correspond to the model used for the verification, therefore it becomes
impossible to assure that the system still satisfies the criteria in the original specification
and the model also loses its use as correct documentation of the system.
A solution to get around this problem is to generate the components of the system from
the model. This eliminates the need to maintain the source code and the model separately,
and the possibility of a change in the source code that doesn’t get done to the model due
to tight deadlines. Only the model needs to be changed to change the behavior represented
by it and the code generator regenerates the source code in accordance to the model.
Besides ensuring that the source code is always in correspondence to the model, the co-
de generator also makes more consistent source code than what manual implementation
would result in, so the readability of the code doesn’t deteriorate as much during the de-
Although model based code generation is certainly a useful solution for some problems, it
is also important to note that it is not a solution for all problems. Obviously we only want
to use the Petri nets to model the interactions between the components of a distributed
system. The tasks of the individual components should be modeled in other formalisms
or - if the component is simple enough - they should be implemented manually. Therefore
it is required for the source code generated by the code generator to be able to cooperate
with code generated from other formalisms and with manually implemented code in the
Distributed systems can consist of devices as limited in resources as microcontrollers and
mobile devices, but high performance servers and embedded systems with architectures
more similar to desktop computers can also be parts of distributed systems. Therefore it
is a long term goal to make the code generator be able to generate source code that is
compilable for any of those devices.
My thesis is about the design of a code generator that satisfies most of these criteria.