Hard real-time embedded distributed systems pose huge demands in their implementation which must contain as few faults as possible. Over the past years, model-driven development and automatic code generation have proven to effectively reduce design faults in those systems. Still, models are mainly used for parts of the systems’ functionality and most solutions do not address the generation of a whole system. In this paper we will showcase an approach for code generation for entire systems. A crucial step is the semantically correct realization of operating modes defined in the model. If they are not changed synchronously, a distributed system will show unpredictable behavior. We will demonstrate how a reliable transition between operating modes, even for a distributed system, can be achieved. Our approach is exemplified using a case study we carried out recently.