|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Java ME JVMs for Embedded Environments
JVMs for Embedded Environments
By: Glenn Coates
Sep. 1, 2001 12:00 AM
While representing my company at JavaOne this year, it was apparent that many Java engineers are becoming more interested in the issues surrounding JVM selection and integration. Many questions were asked concerning the trade-offs involved in the different ways of implementing the JVM. This article is aimed at helping device manufacturers, OEMs, and J2ME application engineers understand the issues - and at helping to initiate further questions when talking to JVM vendors.
What Are the 'Risks' Associated with Java?
Code Bloat
Compile Stalls
Profiling Stalls It's worth remembering that any of this extra processing can be easily hidden from the user. Simply increasing the clock speed from say 25MHz to 200MHz will do the trick, but the battery power of the device will last for only a day instead of a week!
What Are The Different Types of VMs?
Interpreter
Optimized Interpreter The optimized software must exist for your hardware, OS, and JVM.
JIT A common misconception with JIT is that the result is an application that will run as quickly as an equivalent native C application once the compilation is complete. This isn't the case as the application is still a Java application and still runs within the Java domain. Depending on the implementation, it may compile the byte code at different stages of execution and may compile the code using different models. We should also remember that the rest of the Java subsystems still run, such as the garbage collector, and threading kernel. While JIT does bring big improvements in speed, it unfortunately also carries two main risks: code bloat and compile stalls. First, depending on the approach taken, at some time the executing block of Java byte code will need to be compiled into native processor instructions. This obviously requires processing power. (Improvements will be possible via pre-JIT to reduce these risks; however, Ahead-of-Time disadvantages may be introduced.) Second, once the code has been compiled, it needs to be stored. On a mobile device this may mean Flash ROM or even RAM. As Java byte code is abstract, it can represent more functionality in less space than its native processor equivalent instructions - especially in the case of a RISC processor. This code bloat can be anything - up to a factor of 10. Another problem with JIT is the fact that code will be compiled into native instructions, even if that block of code is seldom executed. Again, depending on the device, processor, and implementation, this effect may not always be noticed by the end user, depending how well it's been hidden (see Table 3).
Ahead-of-Time Compilation As with JIT technology, a common misconception with ahead-of-time is that the application will run as quickly as an equivalent native C application. This isn't the case as the application is still a Java application and, once again, still runs within the Java domain (see Table 4). The rest of the Java subsystems still run, such as the garbage collector and threading kernel,
Smart JIT
Hardware Accelerators The use of a hardware accelerator means there is no code bloat as the native instructions are never stored. It also means that there are no software compile stalls, as the Java byte code to native instruction translation is done in the hardware. The software-based JVM is still required. The accelerator vendor typically modifies this so that it uses the hardware accelerator in place of its main interpreter loop and byte code execution unit. The following describes how an accelerator can be used on a "two-sided" smartphone, where one side is used for the 3G baseband critical tasks, and the other is used for the PDA-type noncritical applications.
Single Chip Solution
Dual Chip Solution In order to prevent any degrading in the performance of the main baseband processor (which we shall refer to as the Master), we have introduced another processor to take on the work of the PDA (we shall refer to this as the Slave). This circumvents any performance, stability, or security problems on the more "critical" side of the phone. The Master and Slave typically communicate via a system bus, such as a VCI compatible bus. While hardware acceleration is a much improved method of running Java byte code, there are a number of potential issues with this approach:
Master Processor Work Load Increase In addition to this, the native processor also needs to run the Java subsystems, such as garbage collector, threading kernel, dynamic class loader, and verifier. Again this requires processing bandwidth on behalf of the main processor.
Licensing Cost
Silicon Cost
Native Java Processors Other more complex instructions are implemented by using the core set of byte code machine instructions as microcode, and the few high-level byte codes are executed by firmware, which uses both the microcoded byte codes and the core native byte codes. Any improvements in the core native byte codes have an immediate effect on the higher-level byte codes, which presents a number of interesting optimization opportunities. Looking back at our example of the two-sided smartphone, we use a Master heavyweight processor to process the critical heavy real-time 3G communication tasks, and a lightweight Slave Java native processor for the PDA side of things. It's probably a fair statement to say that the 3G mobile communications processing will only become more complex and time critical as capabilities of the devices and networks increase. Therefore, this processor can be left alone to do its intended job of managing mobile communications. The Slave Java processor is used to provide the processing power for the PDA applications. As with the other VM options, native Java processors can also be field upgraded. One drawback of a native Java processor is that if any legacy native code needs to be run then this can only be executed on the Master processor as the Java chip can only understand Java code.
Which Way to Go? As we can see there are a number of alternatives when considering a JVM for an embedded environment. Still, the decision as to which way to go depends on many factors, including the device, processor, clock speed, available RAM, sophistication of user applications, and the required usability levels. In this article, we've looked at the software techniques that have become more widely used in embedded environments with successful results, and at hardware alternatives that are designed to provide the next generation in performance while keeping memory and processing power to a minimum. In terms of hardware-based VMs, accelerators are the next step toward this "next generation." Native Java processors are a generation further on and are regarded as the ultimate goal. This will open up a new set of exciting possibilities for mobile, wireless, and embedded applications. LATEST JAVA STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK SPONSORED BY INFRAGISTICS
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||