News & Analysis

Java for Embedded Systems

Alexander Katz

7/27/2000 12:00 AM EDT

Java technology is having a profound impact on embedded systems, but exactly how it works eludes many. Still, the benefits of Java are well known. It supports the development of extensible, portable, and downloadable applications, which often results in a significant reduction in development and maintenance costs.

In addition, Java makes it possible for technology developers to respond rapidly to changing market conditions. If implemented appropriately, the Java portions of an embedded application can be isolated from the rest of the application, thereby protecting the mission-critical parts from corruption by the Java portions.

In other words, Java application programs are independent of the operating system under which they run. This feature, central to all considerations about Java, inspires the possibility that a porting system for the Java Virtual Machine (JVM) can be devised that will allow its use with all, or at least a very significant number of the main real-time kernels used in embedded applications.

NSIcom's Software Co-Processor for Java (JSCP), a generic Java implementation for use with embedded applications, is another interesting Java development.


The Java Concept

Java comprises a new and revolutionary set of concepts, developed by Sun Microsystems and intended to facilitate the use of portable software components that can be downloaded dynamically over a network—rather than kept on a local disk or in the local memory of a specific computer. In this way, the client computer need not store all the applications since they can be downloaded from the server whenever required. Consequently, if and when an application terminates execution, it can be retained for future use, modified, or discarded.


The Language

The Java language is a new object-oriented programming language. It is particularly suited to the development of portable application modules. These applications are downloaded over the network and executed on the Java-enabled client target, which should be equipped for this purpose with a Java interpreter environment, named JAE (Java Application Environment) by Sun. A Java-enabled Web browser also includes a Java interpreter.


The Components

The Java development environment compiles the Java source code into byte code. Once compiled, the Java byte code can be placed in a file for downloading through the network to the client target that requests it.

On the target, the Java Virtual Machine within the JAE is responsible for actually executing the Java byte code. It isolates the Java code from the underlying hardware and operating system. Consequently, Java applications are developed only once, but they can run unchanged on any client computer with a Java interpreter, regardless of the specific platform.


Java in Embedded Systems

The use of Java in an embedded environment presents unique challenges, because of the fundamental differences between an embedded system and a general-purpose computer or workstation. These differences must be understood thoroughly in order to appreciate the issues associated with implementing Java in a particular application domain:

  1. The code of an embedded system is usually stored in ROM and thus cannot be modified. Even when the code is stored in some kind of alterable medium, such as Flash memory, there must be a physical way to gain access to the device from an external source so that code updates can be sent to the device.
  2. An embedded system usually lacks secondary storage, such as a hard disk. Without this kind of storage, the system cannot store a library of application code from which it could select and load particular routines on demand. Therefore, the size of the applications is limited to the size of the existing permanent memory device (such as ROM or Flash).
  3. An embedded system might sometimes lack a direct user interface such as a monitor. Rather, it communicates with the operator (if at all) through some specialized device or through a front-end station connected to the embedded application via a specialized bus or network. The lack of a file-system and traditional user interface devices has a special significance for Java-based applications, which rely heavily on the presence of these components.
  4. Embedded applications are designed to satisfy specific performance requirements through the use of appropriate technology; designers won't use 400-MHz Pentiums when a 16-MHz 80188 will do the job. Therefore tight limitations are usually put on memory resources and CPU processing power. Consequently, the scheduling and sharing of the system's resources present major design challenges. Virtually all embedded systems are finely tuned devices that make the most of the available resources while meeting the system's performance requirements.
  5. Typically, an embedded system is highly specialized; it is tightly integrated with the surrounding environment and has demanding requirements for robustness. Since the protection mechanisms—such as address-space boundary protection—that are usually provided by a typical operating system are not available in such an environment, the mechanism of introducing new software into the application should be tightly controlled. This fact has special significance in the context of Java where the programming paradigm is based on dynamic downloading of applets from various sources.
  6. Java was designed and initially implemented to run on Unix workstations. It relies on many services that are available on these systems, such as files, processes, Internet naming services, and memory management hardware, which do not exist in typical embedded systems. Some of these do not make sense in such an environment. For example, a network device might have an IP-address, but it does not necessarily have a domain name nor does it have the capability to address other nodes on the Internet by name. Others do have to be provided by the JVM implementation (e.g. sockets, thread synchronization, memory management).


Implementation Architecture

In order to execute Java code on an embedded system, several key components must be developed or ported to this system. These components have to be tailored to the specific hardware, the kernel, and to some extent the C compiler being used since part of the JVM and its interface layers are implemented in C.

The two main possible approaches are:

  1. Developing a dedicated Java-compatible system exactly fitted to the embedded environment
  2. Adapting Sun's original Java to the embedded environment.

The first approach will produce a traditional embedded system, including all the constraints of this special environment. The second approach has the advantage of compatibility with the de-facto standard that has been already adopted by the industry. Since Java is an evolving language and environment driven by industry needs and rapid technology changes, this factor is crucial.


JVM as an Enabling Technology
More Architectural Concepts

Because Sun's is the preeminent Java technology, it is appropriate to use the JDK as the starting point for embedded Java implementations.

The final result should be a retargetable package that can be readily ported to any combination of hardware, kernel, and C compiler. This package should be able to execute on a variety of real-time operating systems and provide a proper virtual machine environment for the execution of Java byte code. Special design considerations should enable it to coexist with other applications that are running on the same platform, either real-time or non-real-time, while complying with the constraints imposed by the real-time operating system and the application tasking architecture.

This design approach would allow Java functionality to be added to existing, field-proven applications, instead of replacing the applications on a wholesale basis. In addition, a modern software engineering approach like this could incorporate the software reusability concept into the embedded systems field, thereby promoting shorter development cycles and higher software reliability. Finally, this kind of implementation would enable the coexistence and interoperability of new Java code with legacy systems.


JVM Encapsulation

For achieving a truly general solution consistent with the spirit of Java, the porting software should be designed to run on top of practically any commercial or proprietary real-time kernel, or adapt to any application-specific executive. This capability can be accomplished by having a well-defined environment that encapsulates the services that the JVM needs from the underlying system on the target.

The Java language supports parallelism in the form of threads (lightweight tasking). It includes methods for thread management, synchronization, and communication. There are two approaches for mapping the Java threads to the parallel entities of the underlying kernel, typically called tasks:

  1. Mapping each Java thread to a kernel task and utilizing the kernel services to schedule these threads and synchronize them
  2. Dedicating one kernel task to run the JVM and then have the Java threads implemented internally by the Java run-time support system.

Again, there are tradeoffs to be considered when choosing the appropriate method. In the first approach, the services of the real-time kernel are used directly for managing the Java threads and can in some situations outperform the JVM.

Java threads can interact directly with other tasks in the system. However, this approach requires that the overall system is fully tested and certified whenever a new Java thread is introduced or there is a change to the Java code.

In the second approach, the JVM acts as an intermediate monitor. It internally manages the Java threads and ensures that the Java code as a whole performs accurately within its resource boundary. It therefore ensures that the JVM never uses more system resources than have been allocated to the Java application.

The practical meaning of this approach is that once the JVM has been fully tested in a particular environment, new Java applications can be downloaded and executed with almost no need to retest the entire system. However, as mentioned before, such a safety net may come at a price. With certain application profiles, there is additional overhead with scheduling threads and synchronizing them, because two layers of executive software are involved.


Just-In-Time Compilation

Just-In-Time (JIT) compilation is the key technology used to enhance the execution speed of Java programs. However, classical JIT techniques consume excessive amounts of memory, and cannot be used for realistic applications on embedded devices. Embedded Java implementations need JIT techniques that adapt to available memory. Compilation should be reversible and applied only to Java program fragments that are executed intensively.


JVM's Embedded Future

Encapsulation technology can be used to bring the JVM into the embedded environment. The encapsulation technology is generic, thus enabling the JVM implementation for practically any real-time OS or executive, in conjunction with any communication package, and for easy porting on any 32 bit CPU. Moreover, encapsulation technology enables the reuse of the existing non-Java applications, while preserving the robustness required by the embedded environment.





Please sign in to post comment

Navigate to related information

EE Buzz DesignCon

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)

Feedback Form