Mobile Handset Virtual Machine. Outline Virtual Machine Java Virtual Machine Dalvik Virtual Machine 2.

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Introduction.  Professor  Adam Porter 
Android architecture overview
DEPARTMENT OF COMPUTER ENGINEERING
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
A. Frank - P. Weisberg Operating Systems Structure of Operating Systems.
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
Introduction to Android Platform Overview
Intro to Java The Java Virtual Machine. What is the JVM  a software emulation of a hypothetical computing machine that runs Java bytecodes (Java compiler.
Android Introduction Platform Overview.
Mobile Application Development with ANDROID Tejas Lagvankar UMBC 29 April 2009.
Android Introduction Based on slides made by
Arpit Jain Mtech1. Outline Introduction Dalvik VM Java VM Examples Comparisons Experimental Evaluation.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Android Programming By Mohsen Biglari Android Programming, Part1: Introduction 1 Part1: Introduction By Mohsen Biglari.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
ANDROID Presented By Mastan Vali.SK. © artesis 2008 | 2 1. Introduction 2. Platform 3. Software development 4. Advantages Main topics.
Lecture 10 : Introduction to Java Virtual Machine
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Introduction 1-1 Introduction to Virtual Machines From “Virtual Machines” Smith and Nair Chapter 1.
Roopa.T PESIT, Bangalore. Source and Credits Dalvik VM, Dan Bornstein Google IO 2008 The Dalvik virtual machine Architecture by David Ehringer.
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
ANDROID BY:-AANCHAL MEHTA MNW-880-2K11. Introduction to Android Open software platform for mobile development A complete stack – OS, Middleware, Applications.
Created By. Jainik B Patel Prashant A Goswami Gujarat Vidyapith Computer Department Ahmedabad.
A. Frank - P. Weisberg Operating Systems Structure of Operating Systems.
Introduction Why are virtual machines interesting?
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
1 Introduction Read D&D Sec 1.8; Sec 1.13 THE Java tutorial -
Virtual Machines Mr. Monil Adhikari. Agenda Introduction Classes of Virtual Machines System Virtual Machines Process Virtual Machines.
By Adam Reimel. Outline Introduction Platform Architecture Future Conclusion.
Introduction to Programming 1 1 2Introduction to Java.
Java & The Android Stack: A Security Analysis Pragati Ogal Rai Mobile Technology Evangelist PayPal, eBay Java.
RealTimeSystems Lab Jong-Koo, Lim
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
ANDROID OS Ravi Soni MTech (CS) III Sem. W HAT IS A NDROID ? Android is a software stack for mobile devices that includes an operating system, middleware.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
The Basics of Android App Development Sankarshan Mridha Satadal Sengupta.
Computer System Structures
Android Mobile Application Development
Visit for more Learning Resources
Before You Begin Nahla Abuel-ola /WIT.
Chapter 2: Operating-System Structures
Java programming lecture one
Lecture 1 Runtime environments.
Introduction Enosis Learning.
CMPE419 Mobile Application Development
2.1. Compilers and Interpreters
Mobile Handset Virtual Machine
Introduction Enosis Learning.
Application Development A Tutorial Driven Course
Introduction CSC 111.
Virtual Machines (Introduction to Virtual Machines)
Lecture Topics: 11/1 General Operating System Concepts Processes
(Computer fundamental Lab)
Java Programming Introduction
Android Introduction Platform Mihail L. Sichitiu.
Introduction to Virtual Machines
Android Platform, Android App Basic Components
Lecture 1 Runtime environments.
Introduction to Virtual Machines
CMPE419 Mobile Application Development
M S COLLEGE ART’S, COMM., SCI. & BMS
Chapter 3 Software.
Hypervisor A hypervisor or virtual machine monitor (VMM) is computer software, firmware or hardware that creates and runs virtual machines. A computer.
Presentation transcript:

Mobile Handset Virtual Machine

Outline Virtual Machine Java Virtual Machine Dalvik Virtual Machine 2

Concept A virtual machine (VM) is a software emulation of a real machine so that  another operating system can run in the simulated machine  more than one different operating systems can run at the same time Fundamental idea: abstract the real hardware into different execution environments 3

VM Components (1) Three components of a virtual machine  Host: underlying hardware system  Virtual machine manager (VMM): creates and runs different virtual machines  Guest: the emulated operating system on the host system 4

VM Components (2) 5 Non-virtual machine Virtual machine Host VMM Guest

System/Process VM Two major kinds of virtual machines based on their emulation degree of real machines  System virtual machine: it provides a complete system platform to support a complete operating system  Process virtual machine: it runs a single program and supports a single process 6

System VM It usually emulates a platform to run programs where the real hardware is not available to use (for example, running Mac OS on a windows computer) Multiple OSes can co-exist on the same physical hardware and are strongly isolated from each other Popular virtual machine manager products: Xen, VMware Workstation, Sun Virtualbox 7

Process VM It is created when the process is started and destroyed when the process exits. Its purpose is to provide a platform-independent programming environment so that a program can execute in a same way on any platform For example, Java bytecode can run on any platform where there is a Java Virtual Machine and the code does not need to be recompiled. 8

Outline Virtual Machine Java Virtual Machine Dalvik Virtual Machine 9

Java Virtual Machine Java Virtual machine (JVM) is the virtual machine that can execute Java bytecode. It is the execution part of the Java platform It helps Java to achieve its goal “write once, run anywhere” by hiding the differences between different operating systems 10

Java Bytecode Java bytecode is the instruction set for Java virtual machine Each bytecode consists of two parts  One or two bytes that represent the instruction  Zero or more bytes for parameters Java compiler compiles Java code into Java bytecode. The Java programmer does not need to be aware of or understand Java bytecode 11

Example of Java Bytecode 12 Java Compiler Java Code Java Bytecode instructionFucntion iconst_nPush the integer constant n onto the stack istore_nStore an integer value into the variable of index n iload_nLoad an integer value from variable of index n sipushPush a short integer onto the stack iinc n iIncrease variable of index n by i

JVM Workflow (1) Java source code is compiled into Java bytecode which is stored within.class files Each class in Java source code will be compiled into one.class file. The.class files are read and interpreted by JVM 13

JVM Workflow (2) 14 A.class A.java Java Compiler B.class Class Loader Bytecode Interpreter Java Virtual Machine Compile source code Java API Host system (Windows, Linux, etc)

JVM Components (1) Class loader  Loads.class file into memory  Verifies bytecode instructions  Allocates memory for the program 15

JVM Components (2) Runtime data area  Method area: it stores class and method codes  Heap: it is the place where Java objects are created  Java stacks: they are places where Java methods are executed  Program counter (PC) registers: they store memory addresses of the instructions which to be executed  Native method stacks: they are places where native methods (e.g. C programs) are executed. Native method is a function which is written in another language other than Java 16

JVM Components (3) Native method interface: it is a program that connects native method libraries with JVM for executing native methods Native method library Execution engine: it contains the interpreter which converts Java bytecode into machine code 17

JVM Architecture 18

Java Runtime Environment 19 We usually install the Java Runtime Environment (JRE) on our computers to use the Java platform JRE consists of the JVM and Java APIs

Outline Virtual Machine Java Virtual Machine Dalvik Virtual Machine 20

Introduction Dalvik virtual machine (DVM) is the process virtual machine in Google’s Android operating system. It executes applications written for Android. It is open-source software which was originally written by Dan Bornstein, who named it after the fishing village of Dalvik in Iceland 21

Why DVM not JVM When Google selected Java as the language for developing Android applications, it chose DVM instead of JVM for several reasons:  Though JVM is free, it was under GPL license, which is not good for Android as most the Android is under Apache license  JVM was designed for desktops and it is too heavy for embedded devices  DVM takes less memory, runs and loads faster compared to JVM 22

Android Architecture 23 Virtual Machine C/C++

Dalvik Bytecode Dalvik bytecode is the instruction set for Dalvik virtual machine Android programs are firstly compiled into Java bytecode which is in.class files. A tool called dx then converts Java bytecode into Dalvik bytecode 24

Dalvik Bytecode VS Java Bytecode 25 Java source code Dalvik bytecodeJava bytecode

Dalvik Bytecode VS Java Bytecode 26

DEX File A.dex (Dalvik EXecutable) file is used to store the Dalvik bytecode. It is converted from.class files and executed on the DVM The.dex file has been optimized for memory usage and the design principle is sharing of data It uses shared, type-specific constant pools as its primary mechanism for saving memory 27

Constant Pool Concept A constant pool is a table stores all constant values (e.g. string constants, field constants, class constants, etc.) used within a Java class. Constant values are referred to by their index in the constant pool rather than stored throughout the class Constant pool is the biggest part of the Java class file and takes up 61% of the file size 28

Constant Pool Optimization (1) Although average size of one.class file is quite small, the size still matters because the time to read file from storage is a dominant factor in VM startup time.dex file optimizes the constant pool when converted from.class files 29

Constant Pool Optimization (2) In the.class file, each class has its own private, heterogeneous constant pool. It is heterogeneous because all types of constants (field, string, class, etc.) are mixed together In the.dex file, all classes share the same type- specific constant pools. Duplication of constant values across different classes is eliminated 30

Constant Pool Optimization (3) 31 Java Source Code (.java files) Heterogeneous Constant Pool Other Data.class Heterogeneous Constant Pool Other Data.class Heterogeneous Constant Pool Other Data.class Strings Constant Pool Other Data.dex Class Constant Pool Field Constant Pool Method Constant Pool Java Compiler dx tool

Memory Saving Evaluation The Android team found that.dex file format cuts the size in half of some common system libraries and applications within Android system 32 CodeSize of.class Files (bytes) Size of.dex File (bytes) Common System Libraries21,445,320 (100%)10,311,972 (48%) Web Browser App470,312 (100%)209,248 (44%) Alarm Clock App119,200 (100%)53,020 (44%)

Zygote (1) Zygote is another concept used by Android to speedup VM performance Every Android application runs in its own instance of the VM, so VM instances should be able to start quickly when a new application is launched Zygote enables code sharing across different VM instances and provide fast startup time for new VM instances 33

Zygote (2) Zygote is a VM process which starts at system boot time. When Zygote starts, it initializes a VM instance and preloads core library classes which are good candidates for sharing across processes Zygote will sit and wait for socket requests from other processes who need new VM instances Cold starting VM takes a long time. Once a request occurs, Zygote will fork a new VM instance from itself and the startup time will be minimized 34

Zygote (3) 35

Android Runtime Android Runtime (ART) is an application runtime environment used by Android operating system It is designed to replace Dalvik virtual machine. It supports standard.dex file to maintain backward compatibility ART came out as an alternative runtime environment in Android 4.4 Dalvik virtual machine was entirely replace by ART in Android

Java Source Code to Android App 37 Java Source Code (.java files) Dalvik Bytecode.dex file Java Compiler dx tool.class file Java Bytecode Resource files Android App.apk file Package Builder

Android Application Launch Procedure Many things happen in the background when a user clicks on an icon and launch a new application  The click event gets routed to activity manager.  The activity manager sends parameters to Zygote process over the socket connection and creates a new process  Zygote forks itself and returns the new process ID  The activity manager attaches the new process to the application and the application’s classes will be loaded into the process’s memory  The application is launched 38

References (1) overview.pdf overview.pdf architecture.html#.VOupzfnF9t8 architecture.html#.VOupzfnF9t8 between-dvm-and-jvm-why-android-opted-for-dvm between-dvm-and-jvm-why-android-opted-for-dvm 39

References (2) part-2.html part-2.html launch.html launch.html