embedded systems java in an embedded system c.-z. yang czyang sept.-dec. 2001

50
Embedded Systems Java in an Embedded System C.-Z. Yang http://syslab.cse.yzu.edu.tw/~czyang Sept.-Dec. 2001

Post on 22-Dec-2015

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

Embedded SystemsJava in an Embedded System

C.-Z. Yanghttp://syslab.cse.yzu.edu.tw/~czyang

Sept.-Dec. 2001

Page 2: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 2

元智大學資訊工程系

Java for Embedded Systems

Deepak Mulchandani

Wind River Systems

Page 3: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 3

元智大學資訊工程系

Shift based on Internet

• Traditional distinctions between desktop systems and embedded systems are on the basis of functionality.

• Now the emergence of the Internet is shifting the idea of fixed-function embedded devices toward more open systems offering some form of network connectivity.

Page 4: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 4

元智大學資訊工程系

Embedded Java

• Several reasons– With Java, developers can target a platform-independent API

and migrate their applications to different devices without recompiling or re-verifying them.

– The OO nature of Java supports well-structured development and software reuse.

– The Java Virtual Machine provides a dynamic platform with a secure execution environment.

• Java is not just a programming language; it is a complete dynamic platform that requires extra infrastructure to run on embedded devices.

Page 5: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 5

元智大學資訊工程系

Considerations

• Accordingly, its suitability to an application depends on the device requirements.

• Developers must consider resource, integration, and real-time performance requirements to determine Java’s suitability to an application.– For example, the bias of the language and platform toward

32-bit processors would not be appropriate for devices with 4-, 8-, or 16-bit CPUs.

Page 6: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 6

元智大學資訊工程系

Considerations

• Issues related to memory management and the interpreted Java VM would hinder applications that demand strict real-time performance.

• Another consideration is the size of the complete Java platform. – Many people believe that support of a Java VM is all you need

to run Java applications.– However, to compute the total size of the Java platform

correctly, you must add the size of the Java VM, Java API package, Java application, and associated native-code libraries.

Page 7: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 7

元智大學資訊工程系

Embedded Java Platform Architecture

Page 8: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 8

元智大學資訊工程系

Overview

• Two sample devices

– The RTOS supports multithreading (scheduling), memory management, networking, and peripheral management for the Java VM.

Page 9: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 9

元智大學資訊工程系

Architecture of the Java Platform

• The architecture

Page 10: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 10

元智大學資訊工程系

Java VM

• The Java VM depends on an RTOS to provide hardware-specific functionality for running Java applications.

• This functionality includes threading, memory management, and execution of native code.

Page 11: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 11

元智大學資訊工程系

Java VM

• The device supports four Java API packages: java.awt, java.net, java.io, and java.math.

• The packages are layered directly on top of native-code libraries– This technique supports the abstraction of Java application

s from platform-specific functionality and allows the Java API package to remain portable across platforms.

Page 12: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 12

元智大學資訊工程系

The Java APIs

Page 13: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 13

元智大學資訊工程系

Evolution of Java

• As JDK 1.0.2 evolved to JDK 1.1, the Java API package was enhanced at a penalty of size.– As a result, many embedded manufacturers recognized the

benefits of Java but hesitated to pay the added resource requirements it places on their devices.

• To address this weakness, JavaSoft developed four APIs that targeted different market segments: JDK, PersonalJava, EmbeddedJava, and Java Card.

Page 14: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 14

元智大學資訊工程系

Resource Requirements

• Four APIs

Page 15: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 15

元智大學資訊工程系

The Proper API

• JDK 1.1.4

Page 16: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 16

元智大學資訊工程系

Scaling Java Class Packages

• Static method – The static method analyzes the application code and compi

les a list of the referenced Java API classes and packages.

– Using the compiled list, you can go through the Java class package and remove the unnecessary packages and classes.

– The static method is quick, but prone to some error in missing classes that are not directly referenced through the source code.

Page 17: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 17

元智大學資訊工程系

Scaling Java Class Packages

• Dynamic method– The dynamic method requires you to run the application co

de and generate a log of Java classes your application references.

– To perform this analysis, you can run your Java application on a Java VM with the -verbose flag enabled.

– This technique will generate a fairly complete list of all the Java classes referenced in an application.

– The dynamic method is a lot more accurate than static analysis since it compensates for classes loaded from other sources such as the network.

Page 18: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 18

元智大學資訊工程系

Breaking up the JDK

• Two separate archives– rt.jar

– i18n.jar

• The impact of a 1.3 Mbtye class package is a lot easier to absorb on an embedded device.

• Note that the 1.3 Mbyte figure is for the JDK class package.

• The PersonalJava and EmbeddedJava class package will be much smaller.

Page 19: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 19

元智大學資訊工程系

Memory Management AndGarbage Collection

Page 20: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 20

元智大學資訊工程系

Memory Management

• Java applications do not have any explicit mechanisms for memory management.

• The allocation and deletion of objects is performed with cooperation between the Java VM and the garbage collector. – On the one hand, this isolates the developer from the proce

ss of keeping track of memory use in an application.

– On the other hand, the garbage collection process is nondeterministic and cannot be scheduled.

Page 21: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 21

元智大學資訊工程系

The Problem

• As a result, you cannot be sure exactly when the Java VM will clean up the object heap, since – it runs the garbage collector as a low-priority thread and

– does not include mechanisms to directly control the behavior of the garbage collector.

• The Java API package does provide a method, System.gc(), to call the garbage collector, but this method does not guarantee anything; it merely sends the Java VM a suggestion to clean up the object heap.

Page 22: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 22

元智大學資訊工程系

Object Heap States in the Java VM

• The information is based on ratios and divided into three categories: greengreen, yellowyellow, or redred state. – When there is no shortage of memory, the Java VM

operates in the greengreen state.

– When memory drops below a specified threshold, the Java VM enters the yellowyellow state, which means it should schedule a garbage collection soon.

– If the application keeps executing, the Java VM enters the redred state, which means the object heap is almost saturated and garbage collection needs to be done immediately.

Page 23: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 23

元智大學資訊工程系

The Java VM Threading Model

• An example

Page 24: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 24

元智大學資訊工程系

The Problem of the Garbage Collector

• The garbage collector poses a problem in that it tends to lock down all the Java threads while it cleans out unused objects from the system.

• The lockdown ensures that the state of the heap remains stable, but it adversely affects real-time performance of Java applications.

Page 25: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 25

元智大學資訊工程系

The Problem of the Garbage Collector

• A simple workaround to this problem is to continue to allow the RTOS to manage operations of the device—interrupts, device management, and task scheduling—with those tasks running at a higher priority. – A Java application should not be written to rely on any

RTOS or system-specific functionality, nor should it make any assumptions about scheduling or timing.

– Any specific portions of the Java application that are performance-critical can be implemented in native code.

Page 26: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 26

元智大學資訊工程系

Java Performance

Page 27: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 27

元智大學資訊工程系

Performance Issue

• The Java class file format and the Java VM– the cross-platform promise

• On the target device, each Java bytecode is executed using the interpreter loop embedded in the Java VM.

• The Java VM interpreter loop is responsible for translating each Java bytecode into equivalent native-code functions while the application executes.

Page 28: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 28

元智大學資訊工程系

Performance Issue

• Java bytecode applications tend to run slower than native applications since – optimizations cannot be performed at runtime and

– the translation is a fairly serial process.

• Based on early benchmarks, Java applications tend to run 20 to 30 percent slower than applications written in C.

• This is not a significant problem for small applications, but it can be a serious issue when it comes to running any sizable applications.

Page 29: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 29

元智大學資訊工程系

Average Execution-time Allocation

• The table shows the time spent in native code execution at 1 percent of overall execution time.

Page 30: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 30

元智大學資訊工程系

Optimization Technology

• A specific optimization technology to improve Java application performance can only be applied to speed the interpretation of bytecodes.

• The techniques to choose from include the ROMizing technology presented earlier.

• Other solutions focus on three main areas: Java native compilers, JITs, and Java Chips.

Page 31: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 31

元智大學資訊工程系

Java Compilers

• Using Java Compilers allows developers to write inter-operable Java, C, and C++ code.

• Pros– The benefits are the increased performance by having your

system rely more on the mature native compilers rather than bytecode-based Java compilers.

• Cons– On the downside, you lose the benefits of the dynamic Jav

a platform as soon as portions are converted to native code. – Also, for device updates you will have to rely on native co

de patches rather than using the Java VM to selectively update certain aspects of your application.

Page 32: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 32

元智大學資訊工程系

Just-In-Time Compilers

• Just-in-Time Compilers are a popular approach to improving Java performance.

• JIT compilers convert Java bytecodes to native code while an application is running.

Page 33: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 33

元智大學資訊工程系

Just-In-Time Compilers

• The JIT approach does not work as well:– If the application performs operations such as graphics or

floating-point operations, then JIT compilers do not give a large performance boost.

– If the application constantly creates objects, the garbage collector would interfere with the operation of the JIT.

– If performance is mostly a function of optimizations, JIT compilers are limited by their status as a runtime component.

• JIT compilers can also take up large amounts of RAM.

Page 34: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 34

元智大學資訊工程系

Java Chips

• Java chips have been offered as a hardware option to improve Java performance.

• You still need a Java VM (without interpreter loop) and RTOS to put together a complete Java platform, so the Java chips are primarily performance enhancers.

Page 35: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 35

元智大學資訊工程系

Embedded Internet Systems

Page 36: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 36

元智大學資訊工程系

Comparisons

• Desktop v.s. Embedded Internet Systems

Page 37: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 37

元智大學資訊工程系

Two Java Tech Paths

• Java for “soft” embedded systems with fewer resource and response-time constraints.– The “soft” Java approach ports a subset of the desktop

Java VM directly into the RTOS environment.

– Although it is optimized for small memory footprints and diverse visual displays, this results in a relatively large (by embedded standards) and high-cost end product.

• Real-time Java for deeply embedded “hard real-time” systems.

Page 38: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 38

元智大學資訊工程系

Hp’s Native Java Compilers Approach

• HP is also developing a third approach—native Java compilers—which translate Java programs directly into CPU machine code.

• Although native compilers break Java’s original mantra of platform neutrality, they run much faster than Java bytecodes that are interpreted by the Java VM for execution on the CPU.

Page 39: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 39

元智大學資訊工程系

Embedded Java in a Web-Based Teleradiology System

Andrea Abrardo and A.L. Casini

University of Florence

Page 40: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 40

元智大學資訊工程系

Medinet

• This paper present a pilot teleradiology application based on embedded Java in the Web. It investigates how the use of Java can solve the issues involved in the implementation of a teleradiology system over the web.The proposed solution is being tested in real hospital environments and can be used as the backbone for the development of complex multiplatform client-server applications in the field of teleradiology.

• Medinet is a Web-based solution for teleradiology currently undergoing clinical evaluation as part of the European Union advanced communications technologies and services program. The system uses embedded Java applets to permit remote access to radiologic data and diagnostic services.

Page 41: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 41

元智大學資訊工程系

Main Network Requirement of Today’s Telemedicine Application

• Enable the sharing of data across heterogeneous network environments.

• Enable the implementation of strong security measures.– Secure identification

– Access control strategies

– Encryption methods - privacy of patient data

Page 42: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 42

元智大學資訊工程系

Overall Architecture of Medinet

• The overall architecture

Page 43: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 43

元智大學資訊工程系

Access to Remote Medical Image Databases on the Web

• Two models

Page 44: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 44

元智大學資訊工程系

Collaborative Diagnosis through Event Broadcasting

• The event broadcasting method works particularly well with web-based collaborative application. – It fits the Java applet.

– Conference agent must distribute only small amounts of data to the participants.

• The socket interface provides backbone communication and allows the bidirectional transmission of data among the applets and the Java sever.

Page 45: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 45

元智大學資訊工程系

Mednet’s Teleradiology Functions

• Access to Medical Diagnostic Image database– proposed solution

• three tiered

• Indirect Access Method

Page 46: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 46

元智大學資訊工程系

Mednet’s Teleradiology Functions

• Access to telediagnosis services

Page 47: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 47

元智大學資訊工程系

Results

• Users and Performance– users -> threads in Java VM -> performance

Page 48: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 48

元智大學資訊工程系

Results

• Compression or not and Performance

• Latecomers

Page 49: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 49

元智大學資訊工程系

Conclusions

• Managing high-volume images and their processing requires efficient VM.

• The security manager, along with digitally signed applets must be used to give the necessary privileges to the retrieved applets.

• Security of the system must be more sophisticated when dealing with real patient.

• The option to integrate intranet and extranet services with different privilege access.

Page 50: Embedded Systems Java in an Embedded System C.-Z. Yang czyang Sept.-Dec. 2001

[email protected] Embedded Systems - Java in an Embedded System 50

元智大學資訊工程系

ACM Code of Ethics

• As an ACM member I will .... – Contribute to society and human well-being.

– Avoid harm to others.

– Be honest and trustworthy.

– Be fair and take action not to discriminate.

– Honor property rights including copyrights and patent.

– Give proper credit for intellectual property.

– Respect the privacy of others.

– Honor confidentiality.