Real-time Specification for Java (RTSJ)
Some features of the Java language specification, particularly the non-deterministic runtime garbage collections and threading, have hindered the adoption of Java in industries for Real-Time Systems and software applications. Both industry representatives and academics understand this limitation of the application of Java in Real-Time so a workshop at the National Institute of Standards and Technology (NIST) was organized to discuss and propose a draft for Real-Time Specification for Java (RTSJ). This requirement lead to the formation of an expert group in the Java Community Process (JCP) to draft a specification for Java in Real-Time.
Origin of Real-Time Systems
The first proposal for operating a computer in real time, as in control systems, was published in 1950. This publication shows a computer in both feedback (feeding the output to the input) and feed-forward (feeding the input to the output) loops. It was assumed that analog-computing elements would be used but digital computing was not excluded. The first digital computers developed specifically for real time control were for airborne operation. By 1954 a Digitrac digital computer was successfully used to provide an automatic flight and weapons control systems.
The emergence of Real Time Operating Systems (RTOS) in industrial applications started in the 1960s. Process Fortran compilers also made their appearance. The advent of microprocessor in the 1970s and the increase of fast memory began to force attention more on the problems of writing correct and dependable computer control software.
Definition of Real-Time Systems
The definition of real time systems seemed to vary amongst different groups, such as vendors, software developers, practitioners, academics, researchers and so forth. Here are some of the definitions.
- The Oxford dictionary of computing offers the definition as: "A system in which the time at which the output is produced is significant. This is usually because the input corresponds to some movement in the physical world, and the output has to relate to that same movement. The lag (delay) from the input time to output time must be sufficiently small for acceptable timeliness".
The above definition covers different types of systems, from workstations running under Unix operating systems where the user expects to receive a response within a few seconds to aircraft engine control systems which must respond within a specified time and failure to do so could cause the loss of control and possibility of loss of passengers lives.
Here is another definition that is defined in the Journal of Systems and Control Engineering:
- "Real-Times Systems are those which must produce correct responses within a definite time limit. Should computer responses exceed these time bounds then performance degradation and/or malfunctions results".
The following is an alternative definition to the above:
- "Real-Time Systems read inputs from the plant (a physical system to be computer controlled, eg: robot, supermarket automated entrance sliding door, factory automation process, digital camera and so forth) and sends control signals to the plant at times determined by plant operational considerations - not at times limited by the capabilities of the computer systems".
Real-Time Systems and embedded computers are connected to the environment, which it is working in, by a wide range of interface devices that receive and send stimuli. External processes all operate in their own time-scales and the computer is said to operate in real time if actions carried out in the computer relate to the time-scales of the external processes.
Synchronization between the external processes and the internal actions or tasks carried out by the computer may be defined by:
- The passage of time, or the actual time of the day, in which case the system is said to be clock based and the operations are carried out according to a time schedule.
- Actions, which have to be performed not at particular times or time intervals but in response to some events in which case it is said to be event based. For Example, switching-off a freezer when the temperature goes below a minimum set-point and switch it on when temperature rises to a maximum set-point. Event based systems normally employ interrupts to inform the computer system that action is required. Some systems may use polling, that is, the computer periodically asks (polls) the various sensors to see if action is required.
- An interactive based in which relationship between the actions in the computer and the system is much more loosely defined. The requirement is that a set of operations in the computer should be completed within a predetermined time. An automatic bank teller machine is categorized as interactive based synchronization as it requires interactive response from the user (customer) to key-in information relating to a transaction and there is a time-limit to response, example, if there is no user response within 20 seconds, then the card is ejected.
Time Constraints of Real-Time Systems
Real-Time Systems can be further divided into two main categories according to their time constraints.
- Hard real-time: These are systems, which must satisfy the deadlines on each and every occasion. An example is a system, which checks the temperature in a chemical plant process control. The temperature is sampled to read every 10 ms (milli-seconds). The control calculation is carried out and the output value is sent to the temperature-controller. This task must be satisfied.
- Soft real-time: These are systems for which an occasional failure to meet a deadline does not compromise program correctness. Example of soft-real-time constraint is an automatic bank teller machine. Such an automated system is event initiated in that it is started by the customer placing his/her card in the machine. The machine response will be specified in terms of an average response time of say, 15 seconds. The actual response time will vary according to the time of the day.
A hard time constraint obviously represents a much more severe constraint on the performance of the system as compared to a soft time constraint and such systems present a difficult challenge both to hardware and to software developers. Most of real-time systems contain a mixture of activities that can be classified as clock based, event based or interactive based with both hard-time and soft-time constraints.
Types of Programs
The division of activities carried out by a computer control systems into real-time and non-real-time tasks, with further subdivision of real-time tasks into two different types (based on time constraints), arises from the different levels of difficulty in designing and implementing the different types of computer program. Programs involving real-time and interface operations, are substantially more difficult to construct than, for instance standard data processing programs. The following are the main types of programs:
- Sequential : Classical sequential programming actions are strictly ordered as a time sequence, which the behaviour of the program depends only on the effects of the individual actions and their order, thus the time taken to perform the action is not of consequence. There are two requirements for verification. Firstly, a particular statement defines a stated action. Secondly, various program structures produce a stated sequence of events.
- Multi-tasking : This program type differs from the classical sequential program in that the actions it is required to perform are not necessarily disjoint in time, and it may be necessary for several actions to be performed in parallel. The sequential relationships between the actions may still be important. The verification requires the application of arguments for sequential programs with some additions. The task (processes) can be verified separately only if the constituent variables of each task (process) are distinct. However, if the variables are shared, the potential concurrency makes the effect of the program unpredictable. Hence it is not capable of verification unless there is some further rule that governs the sequencing of several actions of the tasks (processes).
- Real-Time: A Real-Time programs differs from the other types in that, in addition to its actions not necessarily being disjoint in time, the sequence of some of its actions is not determined by the designer (developer) but by the environment - that is, by events occurring in the outside world which occur in real time and without reference to the internal operations of the computer systems.
Java Weaknesses for Real-Time Application
There were issues in Java language specification that slows its adoption in real-time control industries. The major problem issues were:
- The garbage collected dynamic memory management could interrupt the execution of applications for unpredictable intervals of time. This originates from the non-deterministic behaviour of the garbage collector, because it chooses when to de-allocate objects from memory heap and in no particular order.
- Thread scheduling. Since the JVM (Java Virtual Machine) relies on the host operating systems scheduler, then the operating system must be capable of real-time scheduling. This is not true for all hosts where JVM is available.
It is vital for critical mission real-time control systems software as in a Nuclear Power Plant, Aircraft Control, Submarine Control, Factory Automation, Airport Aviation Flight Control, Energy and Power Systems Supply, Telecommunication Satellite and so forth to have a deterministic scheduling of events not in an indeterminate state. The risks associated with writing such critical mission real-time software in Java far outweighs the other benefits of Java.