MVM (Multi-Tasking VM) for Mobile Handset by olk11750


									MVM (Multi-Tasking VM)
for Mobile Handset

                      2006. 12.6
                      MASS Lab
               Lee Guewon(이규원)
   Background
   MVM Overivew
    - What is MVM
    - Why MVM
   VM Level Implementation
   Profile Level Implementation
   Multi-tasking Safety
   Summary
   VM for Mobile Handset
       VM is widely used in Mobile Handset
        as an Application Execution Environment

       VM level Application runs on every Handset (with VM)

                         VM App

                 VM        VM        VM

               HS 1       HS 2      HS 3
   VM on Handset SW
       OS (REX) provides Multi-tasking feature
       SW Platform does not (or limited) support Multi-tasking
                                            Applications   App(MIDlet)

                                             Mobile SW

          FS             HS                     UI          Java
         Task           Task                   Task         Task
    rex_wait                              rex_wait
               signal                                       rex_wait

What is MVM?
   MVM (Multi-tasking Virtual Machine)
       Running multiple Java App simultaneously in
        single VM instance (OS Task or Process)
       JVM is always-on

    Single-Tasking      Single-Tasking         Multi-Tasking
          VM                  VM                    VM

        Multiple App. Using SVM          Multiple App. Using MVM
Why MVM?
   Efficiency
       Single VM, Multiple Appliciation
         - No need of separate copies of VM for each Application
       Application can share Immutable data type
          (method byte codes/ Compiled method code etc.)
       Free Memory Sharing

   Application Loading Time
       No need to load VM every time (VM already loaded)

   Provide Powerful Environment for Rich Application
       MP3 Player
       MMS/SMS
       Instant Messaging
       Stock Ticker
       Etc.
MVM Overview
   MVM Architecture

- Resource Management
- Multitasking Safety

- Isolation
- Resource Management
  (CPU/Heap Memory)

- Resource Policies
- New App States
VM level Implementation
   Isolation
       Virtualization of Static Variable
       Synchronization

   Resource Management
       CPU Time (Scheduling)
       VM Heap Memory Management
VM level Implementation
   Isolate and Task
      At Java level, each separated running Java App. Within
      one VM is called Isolate
      At JVM level, each isolate is represented as a task
   Task
     Task consists of one or more threads of execution
     All tasks share
      - Constant Data Structure
      - Runtime Support Function
     Each task has
       - separate namespace for loading Java classes
       - separate set of static variables for each loaded Java class
       - separate class monitor associated
         → allows isolated synchronization at the Java class level
VM level Implementation
   Virtualization of Static Variable
     Static variables are no longer part of the JavaClassDesc
        Memory Object. There is a table of pointers to
        TaskMirrorDesc for each task (indexed by class ID)
     Each task has a separate, private copy of the static variables
        of all the loaded Java class
       Static variables are only global to all threads within a particular
VM level Implementation
   Synchronization
       Synchronization has to be task private
       No Java Object are shared across Task boundaries
       Threads in one task can not block threads in other task
VM level Implementation
   CPU Time Scheduling
       Task and Thread are
        Scheduled by the JVM

   Task Scheduling
       Fair schedule policy
       Not strictly priority-based
       Execution Quota for a Task
        (No starvation)
       Set of API to modify
        priority level for each task

   Thread Scheduling
       Priority Based
       Starvation can occur, but only within a task
VM level Implementation
   VM Heap Management
       Reservations
        - Each task has a reservation of heap memory
        - Configurable and Optional

       Quotas
        - Each task has maximum limit on heap memory
        - Configurable and Optional

   Virtually no Performance Impact
       No impact on allocation speed
       Each task has one or more heap regions
       GC slightly more complex
Profile level Implementation
   New Application State
       Application is said to be in the Foreground has the
        control of Display and User input
       Only one Application can executed at a time
       Zero or more Application can execute in the Background
       Need a API to show the current state of the task

        Foreground            Background

                     task                   task
Profile level Implementation
   Resource Management
     In Multi-tasking, each application have to compete for

   Resource Available for Sharing
     Network Socket
     File or other storage
     Audio
     Display
     User Input (Key input / Touchpad)
     Etc.
Profile level Implementation
   Mechanisms
        Reservation
        Quota
        Revocation
        - Release a resource to another Application (CPU time, Display etc.)

   Policies
        Fixed Partition
        - Initial amount of resources are reserved before App launch
        - Reservation = Quota
        Open for Competition
        - Resource are acquired at runtime
        - No reservation.
        Special cases
        - Exclusive Resources (Display/User Input etc.)
        - Special cases (CPU Time)
Profile level Implementation
   Full Resources Policy Matrix
Multi-tasking Safety
   Multi-tasking Safety with Native code
       Native JVM task can run native code for any task
       Some native code could be written to assume that only one
        Java App. Is running
Multi-tasking Safety
   Static and Global Variable
       At Java level, each task has a separate, private copy of static
        variables of all the loaded Java class
       Native code often has global data
        → Native Data should be shared across all tasks
       Global Native data needs to be replicated for each task
        → Only AMS can create an instance of this class

   Native Code Execution
       JVM scheduler is disabled when VM is executing Native Code
       Synchronous Native Interface (SNI) is used to block a specific
        thread without blocking the entire JVM

    ※ Task safety remains much of an art at this time.
      - needs careful though and understanding of Handset and VM
       behavior → No General Solution yet.
Multi-tasking Safety
   Native Event Handling
       Per-Isolate Java Level Event Queues
       Per-Isolate Native Event Queues
       Event Multiplexer

                                                   VM returns current
                                                  running task (isolate)
   MVM
       Instead of SVM, MVM will be widely used
        in Mobile Handset

   Rich content
       Powerful VM application will be developed
        for MVM enabled Mobile handset

To top