JAVA ME PARALLELISM AND IMPLEMENTATIONS FOR EMBEDDED DEVICES Adam Stirtan.

Slides:



Advertisements
Similar presentations
Android Application Development A Tutorial Driven Course.
Advertisements

MIDP Mobile Information Device Profile Johnny Yau CIS 642 Prof. Insup Lee.
Threads, SMP, and Microkernels
COURSE: COMPUTER PLATFORMS
Android architecture overview
1 Chapter 5 Threads 2 Contents  Overview  Benefits  User and Kernel Threads  Multithreading Models  Solaris 2 Threads  Java Threads.
J2ME 25 July Overview  What is J2ME?  The CLDC and CDC configurations  MIDP and MIDlets  Development Tools  Demonstrations.
Writing Your First MIDlet Running JAVA on a Cell Phone Jon A. Batcheller January 27, 2004.
UNDERSTANDING JAVA APIS FOR MOBILE DEVICES v0.01.
The road to reliable, autonomous distributed systems
Computer Systems/Operating Systems - Class 8
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 10 Java for MIDs Rob Pooley
Developing an Application with J2ME Technology Scott Palmer, Nat Panchee, Judy Sullivan, Karen Thabet, Sten Westgard.
Interactive Visual System By Arthur Evans, John Sikorski, and Patricia Thomas.
INTRODUCTION OS/2 was initially designed to extend the capabilities of DOS by IBM and Microsoft Corporations. To create a single industry-standard operating.
© 2009 Research In Motion Limited Data structures and memory management on mobile devices.
PDA Programming Using J2ME Presenter :涂俊凱 Date : 2003/4/8.
Making Cell Phone Games An Overview Ray Ratelis Guild Software, Inc.
Developing J2ME Applications Mobile and Wireless Networks.
Cosc 4730 Phone Programming in Java An Introduction.
Multithreading in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Java 2 Platform, Micro Edition (J2ME) By Xiaorong Wang.
Introduction to Android Platform Overview
J2ME Java for Mobile Environments Based on J2ME In A Nutshell, by Kim Topley, O’Reilly & Associates Inc., 2002, and Tetris by Alexei Patinov.
An Introduction to the Java ME Project Jens A Andersson.
11 Other Programming Aspects Dr. Miguel A. Labrador Department of Computer Science & Engineering
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Michael Brockway Advanced Applications Development in Java J2ME -- Introduction l Introduction / Overview l Java 2 Micro Edition n CLDC n MIDP l Examples.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 11 J2ME and MIDlets Rob Pooley
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Chapter 6 Operating System Support. This chapter describes how middleware is supported by the operating system facilities at the nodes of a distributed.
LWIP TCP/IP Stack 김백규.
Introduction to Embedded Software Development School of software Engineering Introduction to Windows CE.
Framework and application bytecode size CLDC MIDP kXML parser Utility classes Graphics Logic (MIDlet) Application Data (XML file)
Computer Science Wi-Fi App using J2ME and MVC Architecture Advisor : Dr. Chung-E Wang Department of Computer Science Sacramento State University Date:
LWIP TCP/IP Stack 김백규.
J2ME Presented by May Sayed & Menna Hawash. Outline Introduction “Java Technology” Introduction “What is J2ME?” J2ME Architecture J2ME Core Concepts 
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
Java 2 Micro Edition (J2ME) and the world of java
1Basics of J2ME. 2 Objectives –Understand the different java API’s and how the mobile edition API’s fit in –Understand what a mobile configuration and.
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
Microsoft SharePoint Server 2010 for the Microsoft ASP.NET Developer Yaroslav Pentsarskyy
Computer Emergency Notification System (CENS)
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Processes Introduction to Operating Systems: Module 3.
The Mach System Abraham Silberschatz, Peter Baer Galvin, Greg Gagne Presentation By: Agnimitra Roy.
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
X-WindowsP.K.K.Thambi The X Window System Module 5.
CS533 - Concepts of Operating Systems 1 The Mach System Presented by Catherine Vilhauer.
Jini Architecture Introduction System Overview An Example.
The Mach System Silberschatz et al Presented By Anjana Venkat.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
1 Introduction to J2ME Outline MIDP Building J2ME Apps- Tool J2ME Wireless Toolkit Demo MIDlet Programming -- MIDlet Transition States -- Midlet Skeleton.
Enhanced mobile services in Java enabled phones Björn Hjelt Sonera zed ltd Supervisor: Professor Jorma Jormakka.
Advance Computer Programming Market for Java ME The Java ME Platform – Java 2 Micro Edition (J2ME) combines a resource- constrained JVM and a set of Java.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
1 Mobile Operating Systems BY:- Aashish Uppal CSE-1/7 th Sem (63/ )
The Java Platform Micro Edition Java ME
Java N Amanquah.
Operating System Structure
MOBILE DEVICE OPERATING SYSTEM
Wireless Instant Messaging Using J2ME
Android Topics UI Thread and Limited processing resources
Java for Mobile Devices
(Computer fundamental Lab)
CS122B: Projects in Databases and Web Applications Winter 2019
Presentation transcript:

JAVA ME PARALLELISM AND IMPLEMENTATIONS FOR EMBEDDED DEVICES Adam Stirtan

for (int i = 0; i < slides.size(); i++)  What is Java ME and why should you care  The virtual machine and you  The phone you can’t break (go ahead and try)  Implementation details  Minority report (end results)

Java Micro Edition  A Java platform designed specifically for mobile and embedded devices  Devices include over 2 billion cellular phones and smart cards, Blu-ray players, VOIP telephone systems  Allows easy development for an extensive array of markets using existing Java knowledge

Java ME Structure Java SE Java ME MIDP CLDC Implementation Optional Packages Implementation Java Platforms reside on host operating systems

Java ME Architecture Profile Layer (Minimum set of API features) Configuration Layer (Available libraries for categories) Java Virtual Machine (Customized JVM for device OS) MIDP Profile Layer (Interface, Storage, Network) CLDC MIDP

Key Java ME Ideas  Aimed at being highly portable and extendable  Once aimed at low-end devices (CDC for high-end) but technological convergence is blurring the lines  Configurations are horizontally defined for categories while profiles are vertical and specific to the family of devices

CLDC  CLDC: Connected Limited Device Configuration  A specification of a framework for Java ME applications which describes the basic set of libraries and VM features which must be present  Abstracts low level device interaction which runs optimally on restricted hardware devices

CLDC (Continued)  Entire Java libraries are resident in devices 160 KB ROM with minimum 192 KB allocated for VM RAM  Compared to Java SE, many features are rewritten entirely for CLDC or are entirely absent  As of 2010 there are two version of CLDC which devices can implement, 1.0 and 1.1

CLDC Java vs. Java SE  Version 1.0  Floating point math and Java data structures are not present, this is due to minimum requirement of 16 MHz processor  Version 1.1  Serializable interface is not supported  No thread groups or daemon threads  Java reflection are altered and incompatible with SE  Limited error handling where runtime errors are handled by terminating device or restarting application

MIDP (Acronyms Shmacronyms)  Java ME devices all implement a profile  The most commonly used is the MIDP (Mobile Information Device Profile) which is aimed at mobile devices such as phones, embedded devices use the Personal Profile instead  Profiles are subset of the CLDC and classes live in the javax.microedition.* namespace

MIDP (Continued)  MIDP provides a rich set of features to devices  javax.microedition.rms  Persistent form of storage for VMs using CRUD  javax.microedition.messaging  Optional wireless messaging with SMS and MMS  javax.microedition.lcdui  GUI elements which are drawn on the screen

Machines running machines  The CLDC is responsible for running multiple Java applications inside a single OS process  The Java applications run on their own Java VM  In previous releases of CLDC (on old phones you might have owned) it only ran single Java applications, running more than one meant separate OS processes which was not possible with old hardware

So where is the parallel?  It’s true, we don’t have traditional multi-processing inside Java ME due to lack of processors  Primary reason at this point is battery life (it sucks)  But… And it’s a big one…. Parallelism is achieved through concurrent virtual machines inside Java ME and through standard Java threading we all love and hate

The Rundown  Since Java applications are running in their own VM if an application encounters an error it can terminate in a consistent manner  Each application is isolated from the others which prevents deadlock and corruption in other running applications on errors in one  Java ME Multitasking means multiple virtual machines within a single OS process

The CLDC VM  Pure 32-bit virtual machine  Provides large address space and scalable architecture  Compact object layout  Objects have two parts: the header and body - header provides reflective information and hash coding (low memory compared to Java VM) while the body contains object fields  Fast thread synchronization  Uses a variant of block structured locking found in Java VM, as a result performance is no longer a bottleneck

Machines in machines IPC OS Process (System threads, garbage collection, memory allocation) Java Operating System MIDlet Thread Java VM IPC

Java ME IPC  Inter-Process Communication channels are the solution to allowing concurrent VMs to talk with each other  Java API libraries include the classes ‘PipedInputStream’ and ‘PipedOutputStream’  Streams are managed by the global VM to direct stream traffic to the correct destinations

Michael J. Fox Flynn  Dual architecture being utilized to accomplish concurrent virtual machines  The entire Java operating system could be thought of as a SIMD architecture, while inside virtual machines are SISD  This creates a parallel software architecture

Programming with MIDP APIs  The combination of CLDC and MIDP provides a complete environment for creating applications  The core of a MIDP Profile is a MIDlet application which extends the MIDlet class to allow the application management software to control the MIDlet and communicate states changes  MIDlet class provides: Invoking, pausing, restarting and terminating MIDlet applications

Breaking a MIDlet  Many new problems exist on embedded systems  We have to account for things such as receiving a phone call, SMS, MMS, or external data services invocations during execution and allow the external OS or host VM to take control  MIDlets must be able to live in different states to accomplish this

United MIDlet States of Java ME  Three possible states for a MIDlet to be in  Running in the foreground (Active)  Running in the background (Active without UI)  Suspended in the background (Inactive)  In active states MIDlet can respond to all events  In background can respond to all events except keys, camera, speaker and microphone  Inactive MIDlets must have their VMs notified by OS

2 Classes of MIDP APIs  User Interface API  Based upon a succession of displayable screens  Each screen contains data and commands  The API handles commands and changes the display  Persistent Storage API  Organize and manipulate the devices database  Maintains information across multiple invocations

System.out.println(“Hello World!”); import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class COSCMidlet extends MIDlet implements CommandListener { private Command exitCmd = new Command("Exit", Command.EXIT, 1); public COSCMIdlet() { } protected void startApp() throws MIDletStateChangeException { Display display = Display.getDisplay(this); Form mainForm = new Form(“Hello COSC"); mainForm.addCommand(exitCmd); mainForm.setCommandListener(this); display.setCurrent(mainForm); } public void commandAction(Command c, Displayable d) { if (c == exitCmd) { destroyApp(false); notifyDestroyed(); } } All apps extend MIDlet Simple “Hello World” Allows exiting with menu

Threading (in) a nutshell  Managed by the OS  No shared memory space  Communication only with VM defined inter process communication channels (IPC)  Managed by the containing VM  Shared memory space  Single sequential flow of control  10 threads in CLDC Java ProcessJava Thread

Java Multithreading  Implement the ‘Runnable’ interface  Derived classes override the ‘run’ method  Preserves inheritance for implementation  Extend the ‘Thread’ class  Declare a new Thread and call ‘start’ method  Occupies Java’s single extension heritance  Can also use anonymous inner classes for small jobs

Java UDP Client  Need have threaded method for sending information across network which doesn’t abuse battery life of the device  Allows for the MIDlet to give message to be sent and only activate the network protocol when necessary public synchronized void send(String addr, String msg) { address = addr; message = msg; notify(); }

Java UDP Client (Continued) public synchronized void run() { while (true) { if (message == null) { try { wait(); } catch (InterruptedException e) { } } try { byte[] bytes = message.getBytes(); Datagram datagram = new Datagram(bytes, bytes.length, address); datagramConnection.send(datagram); datagramConnection.close(); } catch (Exception ioe) { ioe.printStackTrace(); } message = null; } }

UDP Client Result  We have a dedicated thread for accessing the network components on the CLDC  Classes which have an instance of the client class can simply use: client.sendMessage(“Hello!”)  Only pitfall is if multiple strings are to be sent, but we could easily modify the String object to a Queue

 Real-time GPS location services allows businesses or parents to track devices on a web interface  Used in vehicles as stand-alone devices or as software applications on handsets  Solutions Into Motion contracted me to port Trackem to a new device which will be shipped as part of a new Java ME device

Sonim XP3 Quest  A new to market device aimed at those who need a rugged phone  ARM-9 Processor  25 MB Memory  176x bit Resolution  You can whack it off your desk (or iPhone) and it will still work

Implementation Overview GPS UDP SQL / Web Server HTTP

Trackem MIDlet  Device needs to in parallel aggregate information from CLDC components to formulate a beacon  Location services (latitude, longitude, altitude)  Accelerometer data  Store and forward persistence  On an interval the beacon is pushed to the server  A web interface allows mapping of where the device has been, its stops, and geo-fence boundaries

CLDC Trackem MIDlet (continued) Storage Location Network User Interface AggregatorUDP Client Trackem MIDlet

The Guardian (Boss of level 9) 

References  Think small with J2ME /wi-j2me/ /wi-j2me/  Understanding MIDP System Threads ading3/index.html ading3/index.html  Using Threads in J2ME Applications hreading2/ hreading2/

References  A portable platform /jw-1107-wireless.html /jw-1107-wireless.html  Introduction to J2ME to-j2me-1.html to-j2me-1.html  Sonim Java Programmers Guide a%20Programmers%20Guide%20-%20PB1.pdf a%20Programmers%20Guide%20-%20PB1.pdf