Upload
dora-robinson
View
219
Download
6
Embed Size (px)
Citation preview
Embedded Java ResearchEmbedded Java Research
Geoffrey BeersGeoffrey Beers
Peter JantzPeter Jantz
December 18, 2001December 18, 2001
Advantages of the Java Advantages of the Java Technology ModelTechnology Model
SimplicitySimplicity– Easier language to learn than traditional C/C++ and still has Easier language to learn than traditional C/C++ and still has
object-oriented methodology.object-oriented methodology. Security and SafetySecurity and Safety
– Java programs have more robust security checking, with the Java programs have more robust security checking, with the RTE creating a “sandbox” where applications can run RTE creating a “sandbox” where applications can run safely.safely.
– Lack of pointers eliminates direct memory accessLack of pointers eliminates direct memory access Portability and Robust DistributionPortability and Robust Distribution
– Applications can be easily developed on desktop systems Applications can be easily developed on desktop systems and ported, with minimal effort, to target device.and ported, with minimal effort, to target device.
– ““Write-once, run anywhere” mentality.Write-once, run anywhere” mentality.
Disadvantages of Embedded JavaDisadvantages of Embedded Java
Huge speed disadvantage. Interpreted Java code is Huge speed disadvantage. Interpreted Java code is still 5-10 times slower than a similar C still 5-10 times slower than a similar C application.application.– Improvements made to JVM technology have enhanced Improvements made to JVM technology have enhanced
this over the years.this over the years.
– Often based on how the application is writtenOften based on how the application is written» A well-written Java program can out-perform a poorly written A well-written Java program can out-perform a poorly written
C programC program
– For embedded applications do we really need to For embedded applications do we really need to interpret code, or can we use interpret code, or can we use native-compiled codenative-compiled code??
Disadvantages of Embedded JavaDisadvantages of Embedded Java
Embedded Java technology still relatively new and Embedded Java technology still relatively new and industry support has been slow to catch-on.industry support has been slow to catch-on.
Biggest disadvantage: Lack of RTOS support or Biggest disadvantage: Lack of RTOS support or standardstandard– Early embedded Java applications were very similar to Early embedded Java applications were very similar to
conventional desktop programs. Fine for some apps, conventional desktop programs. Fine for some apps, but deadline control and interrupt handling are but deadline control and interrupt handling are necessary.necessary.
– Great improvement in this genre since 1998.Great improvement in this genre since 1998.
Real-Time Specification for Java Real-Time Specification for Java Guiding PrinciplesGuiding Principles
Applicability to particular Java environments.Applicability to particular Java environments.– Do not include specs that restrict use to a particular Do not include specs that restrict use to a particular
Java environment.Java environment.
Backward compatibilityBackward compatibility– RTSJ shall not prevent existing, non real-time Java RTSJ shall not prevent existing, non real-time Java
programs, from executing on implementations of the programs, from executing on implementations of the RTSJ.RTSJ.
““Write once, run anywhere” mentality should be Write once, run anywhere” mentality should be followed as much as possible.followed as much as possible.
RTSJ Guiding Principles (cont.)RTSJ Guiding Principles (cont.)
RTSJ should address real-time system practice and RTSJ should address real-time system practice and allow for the incorporation of advanced features in allow for the incorporation of advanced features in the future.the future.
Predictable execution as first priority in all Predictable execution as first priority in all tradeoffs.tradeoffs.– May come at expense of general-computing May come at expense of general-computing
performance, but will allow for greater real-time performance, but will allow for greater real-time integration.integration.
No syntactic extensionNo syntactic extension– RTSJ will not introduce new keywords or other RTSJ will not introduce new keywords or other
syntactic extension to the Java language.syntactic extension to the Java language.
Real-Time Specification for JavaReal-Time Specification for Java
Finalized in November 2001.Finalized in November 2001. Standard specification for garbage Standard specification for garbage
collection, memory management, and collection, memory management, and task/thread control.task/thread control.
Additional classes and extensions to Additional classes and extensions to standard Java JDK.standard Java JDK.– However, no new syntax was necessary.However, no new syntax was necessary.
javax.realtimejavax.realtime Package Package
Real-time specification provides Real-time specification provides modifications to the Java Language Spec. modifications to the Java Language Spec. and JVM Spec.and JVM Spec.
New APIs to enable the creation, New APIs to enable the creation, verification, analysis, execution, and verification, analysis, execution, and management of real-time Java threads.management of real-time Java threads.
New APIs in a standard extension package, New APIs in a standard extension package, javax.realtimejavax.realtime..
Seven Areas of EnhancementSeven Areas of Enhancement
Thread scheduling and dispatchingThread scheduling and dispatching Memory managementMemory management Synchronization and resource sharingSynchronization and resource sharing Asynchronous event handlingAsynchronous event handling Asynchronous transfer of controlAsynchronous transfer of control Thread terminationThread termination Physical memory accessPhysical memory access
Four Memory AreasFour Memory Areas
Scoped MemoryScoped Memory– Objects have lifetime defined by syntactic scope.Objects have lifetime defined by syntactic scope.
Physical MemoryPhysical Memory– Objects created within specific physical memory Objects created within specific physical memory
regions having certain characteristics.regions having certain characteristics. Immortal MemoryImmortal Memory
– Objects cannot be destroyed; once allocated they stay Objects cannot be destroyed; once allocated they stay until the end of the application.until the end of the application.
Heap MemoryHeap Memory– Objects represent an area of memory on the heap.Objects represent an area of memory on the heap.
Asynchronous EventsAsynchronous Events
Some internal or external event that Some internal or external event that happens.happens.– Not all real-life events are predictable in time Not all real-life events are predictable in time
and frequency.and frequency. System needs to respond to the changing System needs to respond to the changing
environment.environment.– Ability of real-time systems to react to the Ability of real-time systems to react to the
events requires reliable asynchrony techniques.events requires reliable asynchrony techniques.
Major Platforms SupportedMajor Platforms Supported
Operating SystemsOperating Systems– Windows CEWindows CE– LinuxLinux
ProcessorsProcessors– PicoJava – Sun’s Java ProcessorPicoJava – Sun’s Java Processor– StrongArmStrongArm– MIPsMIPs– IntelIntel
Java and Embedded LinuxJava and Embedded Linux
Java does I/O by opening files which are the Java does I/O by opening files which are the Linux device drivers (ex: /dev/mem). Java Linux device drivers (ex: /dev/mem). Java can seek in addition to read, write and open.can seek in addition to read, write and open.
Bootstrapping allows Linux to load necessary Bootstrapping allows Linux to load necessary drivers and networking files and start running drivers and networking files and start running the JVM.the JVM.
Standard Linux distributions with networking Standard Linux distributions with networking support require lots of memory. support require lots of memory.
Improving PerformanceImproving Performance
Java bytecode programs are typically 10 Java bytecode programs are typically 10 times slower than programs written in C or times slower than programs written in C or C++.C++.
How well the program is written is more How well the program is written is more important. A well-written Java program can important. A well-written Java program can equal the efficiency of an average-written equal the efficiency of an average-written C/C++ program.C/C++ program.
Interpreting code uses less ROM.Interpreting code uses less ROM.
Compilation into Native CodeCompilation into Native Code
AOT (Ahead of time) AOT (Ahead of time) JIT (Just in time)JIT (Just in time) Dynamic CompilationDynamic Compilation
AOT CompilationAOT Compilation
Similar to C compilersSimilar to C compilers Tends to create large executablesTends to create large executables Need to re-compile for different platforms Need to re-compile for different platforms
or when loading a different classor when loading a different class Can compile everything including class Can compile everything including class
librarieslibraries
JIT CompilationJIT Compilation
Machine independentMachine independent Higher startup costHigher startup cost Not ideal for embedded systemsNot ideal for embedded systems
– Requires fast CPU, lots of virtual memory and Requires fast CPU, lots of virtual memory and a fast disk drive for paginga fast disk drive for paging
Dynamic CompilationDynamic Compilation
Dynamically compiles code that is being Dynamically compiles code that is being used more frequentlyused more frequently
Typically uses JIT compilersTypically uses JIT compilers Doesn’t require virtual memory, adaptable Doesn’t require virtual memory, adaptable
to available system memoryto available system memory Isn’t guaranteed to meet timing constraintsIsn’t guaranteed to meet timing constraints
– Applications can change the compiler’s thread Applications can change the compiler’s thread priority for greater predictabilitypriority for greater predictability
Other Methods to improve Other Methods to improve PerformancePerformance
Static Linking - place bytecode into ROMStatic Linking - place bytecode into ROM Re-write bytecode interpreter in assembly Re-write bytecode interpreter in assembly
languagelanguage Use a Java ChipUse a Java Chip
Conclusions and SummariesConclusions and Summaries
Recent advances in embedded Java technology Recent advances in embedded Java technology and advent of RTSJ are allowing real-time and advent of RTSJ are allowing real-time capabilities and possibilities in the Java world.capabilities and possibilities in the Java world.
Many current embedded Java systems are non Many current embedded Java systems are non real-time or a limited subset of RTSJ principles.real-time or a limited subset of RTSJ principles.
Sun’s advancements and broad range of Sun’s advancements and broad range of distribution environments make embedded Java distribution environments make embedded Java programming much simpler and more robust.programming much simpler and more robust.