Design Pattern for the Adaptive Scheduling of Real-Time Tasks with Multiple Versions in RTSJ Rodrigo Gonçalves, Rômulo Silva de Oliveira, Carlos Montez LCMI – Depto. de Automação e Sistemas – Univ. Fed. de Santa Catarina (rpg, romulo, montez)@das.ufsc.br Abstract This paper presents a design pattern of an adaptive scheduling based on the management of the tasks execution time, achieved through multiple versions of the tasks, applied to the Real-Time Specification for Java. A structure of classes is used to facilitate the development of tasks, while allowing the independence of the application code from the code responsible for the adaptive control. The design pattern is described through UML diagrams and an example implementation is presented. 1. Introduction The Real-Time Specification for Java (RTSJ) is an extension of the standard Java platform that is able to attend the restrictions imposed by real-time systems, such as predictability and determinism [1, 2, 3]. The RTSJ adds to the Java standard the following characteristics: it adds real-time threads, it allows the execution of code without the interference of the garbage collector, it also allows the control of the localization of objects and the access to memory physical addresses; it implements a manager of asynchronous events and a mechanism for asynchronous transference of control between threads [1, 2, 3]. An area where the RTSJ will be very important in the next years is the network control. In this type of application, the control of industrial processes is made through a network. Sensors, controllers and actuators are spread by diverse processors in a distributed environment. The control of the industrial process presents real-time requirements and it is affected by the delays in the communication network and the involved processors. A way to deal with the inherent difficulties to the fulfillment of real-time requirements in distributed environments is the adaptive scheduling. In dynamic environments that are managed by adaptive scheduling, the conditions in which the tasks are executed are defined during the execution of the application itself. One of the forms described in literature to provide such adaptability is to allow tasks to have many versions. In the case of network control, there can be two versions of the controller, a fast one but of inferior quality, and another one with maximum quality but increased execution time. The execution time of the task can be dynamically modified in run-time. The objective of this work is to elaborate a design pattern defining a class structure capable to encapsulate the code associated with the multiple versions of a task (code that implements different versions of an algorithm). It will facilitate the implementation of new tasks, at the same time it makes the application algorithm independent of the adaptation mechanism. Thus, a programmer can specialize itself only in the development of the application, not having knowledge of how the adaptive control was implemented internally. Another programmer will be responsible for the control classes and the definition of the scheduling algorithm to be used. The main goal is to facilitate the development of real-time applications that apply adaptive scheduling, making possible the reuse of code and allowing the separation of the scheduling algorithm from the application tasks. The use of design patterns represents reduction of costs and greater agility in the implementation. The next sections present the design pattern considered for the adaptive scheduling based on the management of the tasks execution time. UML diagrams show the structure of the solution and its relationships, as well as the events waited during the execution of the system. Experiences had been carried through to evaluate the behavior of this solution and the result is shown. XXV International Conference of the Chilean Computer Science Society - SCCC'2005