Stripping Down Java

March 26, 2009
As expected, my article on “Embedded C Bashing” generated some discussion. So, I thought I better call in some experts to provide advice when it comes to safety and performance. The performance of compilers for languages like Java and C# h

As expected, my article on Embedded C Bashing generated some discussion. So, I thought I better call in some experts to provide advice when it comes to safety and performance.

The performance of compilers for languages like Java and C# has improved to where code generated for adding a pair of integers winds up being a single instruction. Features such as ahead-of-time (AOT) versus just-in-time (JIT) compilation allow Java to be used to address real-time applications.

JSR-001, Real Time Java Specification (RTSJ), is a large and cumbersome standard that addresses just about any real-time configuration imaginable. It includes various types of scheduling for the restricted use of memory that allows the elimination of the garbage collector for time-critical, hard real-time applications with NoHeapRealtimeThreads. So, memory allocation is either static or on the stack. In return, a number of traditional Java run-time checks can be omitted, increasing performance.

TAKING OUT THE GARBAGE Garbage collection support can address many hard real-time applications. The key is predictability. Products like Aonix’s Perc Ultra and DDC-I’s Scorpion implement incremental garbage collection with fixed, distributed overhead that can be tuned. This enables the dynamic memory management issue to be controlled even better than with a C/C++ environment.

Garbage collection is split up the same way as interrupt and time slice support for threads, allowing it to stay ahead of the system’s dynamic memory requirements versus the typical stop-and-collect scenario that isn’t appreciated in real-time applications.

Ole Oest, CTO at DDC-I, notes that Scorpion’s patented real-time garbage collector performs its work time-bound and within the application threads. There is no separate garbage collection thread. The incremental amount of garbage collection work done in each step has an upper bound that can be calculated by the application’s designer. The allocating thread “pays” for the memory by performing a small number of garbage collection steps. The number of steps required can be analyzed to determine the worst-case number of steps required.

Scorpion allows application threads, RealtimeThreads, and NoHeapRealtimeThreads to share memory, giving the latter access to dynamically allocated memory. JSR-302 is a Java 2 MicroEdition (J2ME) system that’s a stripped-down version of RTSJ suitable for safety-critical systems like DO-178B.

“The safety-critical Java subset also has a ‘severely’ restricted library. The advantage is that safety/hard real-time Java is much smaller and simpler than traditional Java. The disadvantage is that the safety/hard real-time Java does not have immediate access to the wealth of capabilities already present in traditional Java,” says Kelvin Nilsen, CTO of Aonix.

“Mechanisms have been developed to allow traditional Java and hard-real-time Java applications to be bolted together to get the best of both worlds. Lowlevel code can be written using the hard real-time technology. High-level application logic, database access, GUIs, and distributed computing can be written in traditional Java, with the option of running this traditional Java code on a real-time virtual machine that has real-time garbage collection,” Nilsen adds.

“Real-time garbage collection addresses the needs of the soft real-time community who might have timing constraints measured in the range of 1 ms to a few hundred ms. Hard real-time Java is suited to timing requirements measured in microseconds,” he notes.

These days, it isn’t enough to just write fast code quickly. The code needs to be safe and secure, meaning it’s as bug-free as possible.

About the Author

William G. Wong | Senior Content Director - Electronic Design and Microwaves & RF

I am Editor of Electronic Design focusing on embedded, software, and systems. As Senior Content Director, I also manage Microwaves & RF and I work with a great team of editors to provide engineers, programmers, developers and technical managers with interesting and useful articles and videos on a regular basis. Check out our free newsletters to see the latest content.

You can send press releases for new products for possible coverage on the website. I am also interested in receiving contributed articles for publishing on our website. Use our template and send to me along with a signed release form. 

Check out my blog, AltEmbedded on Electronic Design, as well as his latest articles on this site that are listed below. 

You can visit my social media via these links:

I earned a Bachelor of Electrical Engineering at the Georgia Institute of Technology and a Masters in Computer Science from Rutgers University. I still do a bit of programming using everything from C and C++ to Rust and Ada/SPARK. I do a bit of PHP programming for Drupal websites. I have posted a few Drupal modules.  

I still get a hand on software and electronic hardware. Some of this can be found on our Kit Close-Up video series. You can also see me on many of our TechXchange Talk videos. I am interested in a range of projects from robotics to artificial intelligence. 

Sponsored Recommendations


To join the conversation, and become an exclusive member of Electronic Design, create an account today!