SlideShare a Scribd company logo
1 of 52
Download to read offline
2006 JavaOneSM
Conference | Session TS-3742 |
Dancing While Gaming—
Multitasking VMs (MVM)
on Real Devices
Jae Hyou Lee Yaniv Shani
Samsung Electronics Sun Microsystems, Inc.
www.samsung.com www.sun.com
TS-3742
2006 JavaOneSM
Conference | Session TS-3742 | 2
Goal
Deeper understanding of Multitasking
VM implementation on real devices
2006 JavaOneSM
Conference | Session TS-3742 | 3
Project Highlights
• A joint collaboration between Samsung
Electronics and Sun Microsystems
• MVM deployment is based on Sun’s JWC1.1.3
• Deploying most of the MSA JSRs
• Tested with hundreds of games and
applications from leading content providers
2006 JavaOneSM
Conference | Session TS-3742 | 4
Agenda
MVM overview
MVM in the configuration level
MVM in the profile level
• The Foreground and Background state
• Resource management
• Multitasking safety
MIDlets in MVM environment
Q&A
2006 JavaOneSM
Conference | Session TS-3742 | 5
Agenda
MVM overview
MVM in the configuration level
MVM in the profile level
• The Foreground and Background state
• Resource management
• Multitasking safety
MIDlets in MVM environment
Q&A
2006 JavaOneSM
Conference | Session TS-3742 | 6
What Is MVM?
• Running multiple applications simultaneously
• Java is always on
• Favorite applications instantly available
MP3 Playing
Chatting
Gaming
2006 JavaOneSM
Conference | Session TS-3742 | 7
MVM Conceptual View
Device H/W
Operating System
Native JVM Task
Configuration Level
MVM
Resource
Manager
App.
Manager
AMS
JSR JSR JSRJSR
Profile Level
Multitasking Safety
Isolation Model
Deployment Guidelines
Legacy Content
New App States
User Experience
Resource Policies
2006 JavaOneSM
Conference | Session TS-3742 | 8
Agenda
MVM overview
MVM in the configuration level
MVM in the profile level
• The Foreground and Background state
• Resource management
• Multitasking safety
MIDlets in MVM environment
Q&A
2006 JavaOneSM
Conference | Session TS-3742 | 9
Isolates and Tasks
Each application runs in its own logical Java
Virtual Machine, called an Isolate.
Within the JVM, each isolate is represented
as a Task. A task consists of one more Java
thread of execution.
2006 JavaOneSM
Conference | Session TS-3742 | 10
More on Tasks…
• All tasks execute in the same single OS
task context
• All tasks share:
• Constant data structure
• Runtime support functions
• Each task encapsulates non-sharable
program state
MVM
2006 JavaOneSM
Conference | Session TS-3742 | 11
Implementation Details
• Each task has a separate, private copy of the static
variables of all the loaded Java classes
• Static variables are only global to all threads within
a particular task
Static Variable
class A {
public static int count;
...
}
Task 1
class A {
public static int count;
...
}
task 2
MVM
• Each task maintains a
private copy of ‘count’
• The Class representation
is shared
2006 JavaOneSM
Conference | Session TS-3742 | 12
Implementation Details
Synchronization
class A {
public static synchronized int open();
}
• Synchronization has to be task private
• Threads in one task cannot block threads in another task
Task 1 Task 2
MVM
A.open() A.open() A.open() A.open()
Blocking Threads Across
Tasks Isn’t Allowed
2006 JavaOneSM
Conference | Session TS-3742 | 13
Resource Management
• The JVM is responsible for CPU time and
memory resources in order to ensure that all
tasks get their “fair” share
• Other resources, such as network bandwidth
and communication ports are managed by
the profile layer
2006 JavaOneSM
Conference | Session TS-3742 | 14
Resource Management—Scheduling
• Tasks and thread are
scheduled by the JVM
• Fair scheduling algorithm is
used for task scheduling in
order to prevent one task
from taking disproportionate
CPU time
• The ‘Isolate’ class offers a
set of APIs to modify the
priority levels for each task
`
Task 2
Scheduler
MVM
Task 1
Active
Thread
MVM
2006 JavaOneSM
Conference | Session TS-3742 | 15
Resource Management—Memory
• All tasks allocations are conducted from the
same global heap region
• The virtual machine has a bookkeeping
mechanism that accounts for each task total
heap memory consumption
• The JVM injects OutOfMemoryError as needed to
inform tasks that heap space has become scarce
2006 JavaOneSM
Conference | Session TS-3742 | 16
Agenda
MVM overview
MVM in the configuration level
MVM in the profile level
• The Foreground and Background state
• Resource management
• Multitasking safety
MIDlets in MVM environment
Q&A
2006 JavaOneSM
Conference | Session TS-3742 | 17
New MIDlet State in MVM
• An application is said to be in the Foreground when:
• Its displayable controls the display
• It handles event from the user input mechanism
• Only one MIDlet can execute in the Foreground at a time
Foreground MIDlet
2006 JavaOneSM
Conference | Session TS-3742 | 18
New MIDlet State in MVM
Background MIDlet
• An application is in the Background when:
• Its displayable does not control the display
• It does not handle the user inputs mechanism
• Zero or more MIDlets can execute in the Background
at a time
2006 JavaOneSM
Conference | Session TS-3742 | 19
The Application Manager
• A resident MIDIet
• Executed from power on
• Lists the running applications
• A fast way to switch between
running MIDlets
• Display background
MIDIets alerts
2006 JavaOneSM
Conference | Session TS-3742 | 20
Switching a MIDlet to the
Background (1/3)
• Upon a short ‘Hot’ key press the foreground MIDlet
will be placed in the background and main device
menu will be displayed
Short ‘Hot’ Key Press
Short ‘Hot’ Key
2006 JavaOneSM
Conference | Session TS-3742 | 21
Switching a MIDlet to the
Background (2/3)
• Upon a long ‘Hot’ key press the foreground MIDlet
will be placed in the background and the ‘Application
manager’ dialog will be displayed
Long ‘Hot’ Key
Long ‘Hot’ Key
2006 JavaOneSM
Conference | Session TS-3742 | 22
Switching a MIDlet to the
Background (3/3)
Invoking Display.setCurrent(null)
• Upon calling setCurrent(null) the MIDlet will be placed
in the background and the ‘idle’ screen of the device
will be displayed
Display.setCurrent(null)
2006 JavaOneSM
Conference | Session TS-3742 | 23
Interrupting the User
• Background MIDlet calls Display.setCurrent(alert)
• Background MIDlet tries to access a protected API
and a security dialog is prompted
• Noteworthy event occurred in the background
• e.g., Incoming IM while playing a game
2006 JavaOneSM
Conference | Session TS-3742 | 24
DEMO
User Experience Demonstration
2006 JavaOneSM
Conference | Session TS-3742 | 25
Agenda
MVM overview
MVM in the configuration level
MVM in the profile level
• The Foreground and Background state
• Resource management
• Multitasking safety
MIDlets in MVM environment
Q&A
2006 JavaOneSM
Conference | Session TS-3742 | 26
Managing Resources
• In a single-tasking environment, the MIDlet
has access to all of the available resources
• In a multitasking environment, MIDlets have
to compete for available resources
2006 JavaOneSM
Conference | Session TS-3742 | 27
Managing Resources
• Mechanisms
• Reservation
• Quota
• Revocation
• Policies
• Fixed partition
• Open for competition
• Special cases
2006 JavaOneSM
Conference | Session TS-3742 | 28
Resource Management Mechanisms
• A reservation mechanism sets aside a
certain amount of a resource for a MIDlet
and keeps it available for that MIDlet and
that MIDlet alone
Reservation
2006 JavaOneSM
Conference | Session TS-3742 | 29
Resource Management Mechanisms
• A quota mechanism permits a MIDlet to allocate
up to a certain amount of a resource; if the
MIDlet attempts to allocate more resources than
its quota, the attempt fails, even if resources are
actually available on the system
Quota
2006 JavaOneSM
Conference | Session TS-3742 | 30
Resource Management Mechanisms
• The system can revoke a resource from a
MIDlet and give it to another MIDlet
• Resource revocation examples:
• CPU cycles
• Display access
• Audio playback
• Resource revocation doesn’t always have a
dramatic effect on the MIDlet’s execution
Revocation
2006 JavaOneSM
Conference | Session TS-3742 | 31
Resource Management Policies
• Initial amount of resources are reserved
before MIDlet launch
• Resource availability validation during
MIDlet’s startup
• Ensure consistent MIDlet behavior
Fixed Partition
2006 JavaOneSM
Conference | Session TS-3742 | 32
Resource Management Policies
• No reservation
• Resource are acquired and reclaimed at runtime
• May lead to unpredictable behavior
Open for Competition
2006 JavaOneSM
Conference | Session TS-3742 | 33
Special Resource
Management Policies
• Only the Foreground can access the LCD
display and receive key inputs events
• The current displayable of a Background
MIDlet is still updated
Note: vibrate() ,flashBacklight() and tone
playing aren’t honored when invoked from
a Background MIDlet
LCD Display
2006 JavaOneSM
Conference | Session TS-3742 | 34
Sound (1/2)
Special Resource
Management Policies
• Foreground MIDlets are assigned physical player that
can access the audio device resource
• Background MIDlets are assigned a logical player that
only maintains the audio state
• Upon foreground switch the player state is changed
automatically
Logical Player
Physical Player
1
Logical Player
Physical Player
2
Foreground
Switch
2006 JavaOneSM
Conference | Session TS-3742 | 35
Special Resource
Management Policies
• Unique JAD file property to lock audio resources
• Allows a background MIDlet to be audible
• Useful for media players (e.g., the MP3 player,
radio, etc.)
Sound (2/2)
1
Logical Player
Physical Player
2
Logical Player
Physical Player
1
Foreground
Switch
2006 JavaOneSM
Conference | Session TS-3742 | 36
A Full Resource Policy Matrix
Fixed Open Special
Memory X X
CPU X X
File Descriptor X X
Socket X X
Display X
Sound X X
Bluetooth X
Location X
PIM X
2006 JavaOneSM
Conference | Session TS-3742 | 37
Guidelines for Resource
Policy Selection
• Resource policy definition relies on the
underlying platform capabilities and
requirements
• Fixed partition policy should be used for
fundamental resources that are required by
the majority of the applications (e.g., memory,
file, socket)
• Open policy should be used resources that are
used by specific MIDlets and have limited
availability (e.g., Bluetooth, location)
• Display and sound requires special handling
2006 JavaOneSM
Conference | Session TS-3742 | 38
DEMO
Resource Policy Demonstration
2006 JavaOneSM
Conference | Session TS-3742 | 39
Agenda
MVM overview
MVM in the configuration level
MVM in the profile level
• The Foreground and Background state
• Resource management
• Multitasking safety
MIDlets in MVM environment
Q&A
2006 JavaOneSM
Conference | Session TS-3742 | 40
Multitasking Safety
• The native JVM task can run native code for
any task, hence the code must be made
aware of the task on whose behalf it is being
called and possibly allocating resources
• When the task context is established, the
code is considered multitasking safe
• Sun’s JWC software is multitasking safe
2006 JavaOneSM
Conference | Session TS-3742 | 41
Multitasking Safety
Implementation Guidelines
• In some cases a deployment of a profile to MVM
environment requires additional development in order
that the profile will execute properly
Foreground
Switch
Blocking Threads Across
Tasks Isn’t Allowed
2006 JavaOneSM
Conference | Session TS-3742 | 42
Multitasking Safety
• At Java level, each task has a separate, private
copy of the static variables of all the loaded Java
classes
• This is handled internally by the MVM
• Native code often has global data
• Native data is shared across all tasks!
• Global native data needs to be replicated for
each task
• Held as a field of a Java object
• Proper handling for singleton depends on whether
it is meant be used on a per-task basis (the default
behavior for MVM), or by the entire system
Static and Global Variable
2006 JavaOneSM
Conference | Session TS-3742 | 43
Agenda
MVM overview
MVM in the configuration level
MVM in the profile level
• The Foreground and Background state
• Resource management
• Multitasking safety
MIDlets in MVM environment
Q&A
2006 JavaOneSM
Conference | Session TS-3742 | 44
MIDlet Guidelines
• MIDlets developed on top of ‘Canvas’ class will
receive the following notifications:
• Canvas.hideNotify(): When switching to background
• Canvas.showNotify(): When returning to foreground
• MIDP2.0 spec. doesn’t offer APIs for MIDlet that
doesn’t use the ‘Canvas’ class facilities
MIDlet State Detection
2006 JavaOneSM
Conference | Session TS-3742 | 45
MIDlet Guidelines
• Switching to background does not pause a
MIDlet by default
• Legacy content handling
• Some MIDlets (e.g., legacy games) will not run
correctly in the background
• A new JADfile property can request that the MIDlet
be paused when switched to background
In the Background, Am I Paused?
2006 JavaOneSM
Conference | Session TS-3742 | 46
MIDlet State Detection
• Most of the games should be suspended in
background
• Player may be inadvertently killed
• Free up resource that aren’t in use
• No need to continue painting when nobody sees
the results
• Make sure to attract the users attention when
something interesting happens in the
background
How to Behave While Executing in Background?
2006 JavaOneSM
Conference | Session TS-3742 | 47
MIDlet Guidelines
• Return resources when you are done with
them, don’t wait for destroyApp()
• Expect and detect failures in resource
acquisition
• Help the users to overcome resource
acquisition failure
• Expect to see new JAD file properties for
resource policy indication (heap size, special
sound policy, etc.)
Resource Awareness
2006 JavaOneSM
Conference | Session TS-3742 | 48
Boot-time MIDlets
• Launch in the background at boot time
• Bring to foreground upon arrival of
incoming event
• Examples:
• MMS, SMS, IM, Mail clients
• Stock, weather, news
2006 JavaOneSM
Conference | Session TS-3742 | 49
Summary
• MVM in the configuration level:
• Isolation Model
• JVM executes in a single native task context
• MVM in the profile level
• Foreground and Background state
• Resource management and policy
• User experience
• Multitasking safety
• MIDlets in MVM environment
2006 JavaOneSM
Conference | Session TS-3742 | 50
Agenda
MVM overview
MVM in the configuration level
MVM in the profile level
• The Foreground and Background state
• Resource management
• Multitasking safety
MIDlets in MVM environment
Q&A
2006 JavaOneSM
Conference | Session TS-3742 | 51
Q&A
2006 JavaOneSM
Conference | Session TS-3742 |
Dancing While Gaming—
Multitasking VMs (MVM)
on Real Devices
Jae Hyou Lee Yaniv Shani
Samsung Electronics Sun Microsystems, Inc.
www.samsung.com www.sun.com
TS-3742

More Related Content

Similar to Dancing While Gaming—Multitasking VMs on Real Devices

VMUGIT UC 2013 - 03b Trend Micro
VMUGIT UC 2013 - 03b Trend MicroVMUGIT UC 2013 - 03b Trend Micro
VMUGIT UC 2013 - 03b Trend MicroVMUG IT
 
SunGrid: Cloud Computing
SunGrid: Cloud ComputingSunGrid: Cloud Computing
SunGrid: Cloud ComputingUday Subbarayan
 
Mobile Application Development MAD J2ME UNIT 2
Mobile Application Development  MAD J2ME UNIT 2Mobile Application Development  MAD J2ME UNIT 2
Mobile Application Development MAD J2ME UNIT 2Pallepati Vasavi
 
3. CPU virtualization and scheduling
3. CPU virtualization and scheduling3. CPU virtualization and scheduling
3. CPU virtualization and schedulingHwanju Kim
 
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...Olivier DASINI
 
UtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptx
UtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptxUtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptx
UtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptxGrace Jansen
 
DevoxxBelgium_StatefulCloud.pptx
DevoxxBelgium_StatefulCloud.pptxDevoxxBelgium_StatefulCloud.pptx
DevoxxBelgium_StatefulCloud.pptxGrace Jansen
 
VMworld 2013: Unified Endpoint Management in Scale: What’s New with VMware Ho...
VMworld 2013: Unified Endpoint Management in Scale: What’s New with VMware Ho...VMworld 2013: Unified Endpoint Management in Scale: What’s New with VMware Ho...
VMworld 2013: Unified Endpoint Management in Scale: What’s New with VMware Ho...VMworld
 
VMworld 2013: US Air National Guard - DoD Private Cloud Initiative –How Virtu...
VMworld 2013: US Air National Guard - DoD Private Cloud Initiative –How Virtu...VMworld 2013: US Air National Guard - DoD Private Cloud Initiative –How Virtu...
VMworld 2013: US Air National Guard - DoD Private Cloud Initiative –How Virtu...VMworld
 
Nagios Conference 2012 - Jason Cook - Nagios and Mod-Gearman
Nagios Conference 2012 - Jason Cook - Nagios and Mod-GearmanNagios Conference 2012 - Jason Cook - Nagios and Mod-Gearman
Nagios Conference 2012 - Jason Cook - Nagios and Mod-GearmanNagios
 
2014-09-15 cloud platform master class
2014-09-15 cloud platform master class2014-09-15 cloud platform master class
2014-09-15 cloud platform master classCitrix
 
VMworld 2013: Virtualizing Highly Available SQL Servers
VMworld 2013: Virtualizing Highly Available SQL Servers VMworld 2013: Virtualizing Highly Available SQL Servers
VMworld 2013: Virtualizing Highly Available SQL Servers VMworld
 
Government and Education Webinar: Leverage Automation to Improve IT Operations
Government and Education Webinar: Leverage Automation to Improve IT OperationsGovernment and Education Webinar: Leverage Automation to Improve IT Operations
Government and Education Webinar: Leverage Automation to Improve IT OperationsSolarWinds
 
VMworld 2013: Demystifying VMware Mirage: Tips and Tricks for Success
VMworld 2013: Demystifying VMware Mirage: Tips and Tricks for Success VMworld 2013: Demystifying VMware Mirage: Tips and Tricks for Success
VMworld 2013: Demystifying VMware Mirage: Tips and Tricks for Success VMworld
 
Snap protect se_presentation_v3.0
Snap protect se_presentation_v3.0Snap protect se_presentation_v3.0
Snap protect se_presentation_v3.0Mikis Eminov
 
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMayank Prasad
 
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...HostedbyConfluent
 

Similar to Dancing While Gaming—Multitasking VMs on Real Devices (20)

Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
 
Jiro technology
Jiro technologyJiro technology
Jiro technology
 
VMUGIT UC 2013 - 03b Trend Micro
VMUGIT UC 2013 - 03b Trend MicroVMUGIT UC 2013 - 03b Trend Micro
VMUGIT UC 2013 - 03b Trend Micro
 
SunGrid: Cloud Computing
SunGrid: Cloud ComputingSunGrid: Cloud Computing
SunGrid: Cloud Computing
 
Mobile Application Development MAD J2ME UNIT 2
Mobile Application Development  MAD J2ME UNIT 2Mobile Application Development  MAD J2ME UNIT 2
Mobile Application Development MAD J2ME UNIT 2
 
3. CPU virtualization and scheduling
3. CPU virtualization and scheduling3. CPU virtualization and scheduling
3. CPU virtualization and scheduling
 
Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
 
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...
MySQL Day Paris 2018 - MySQL InnoDB Cluster; A complete High Availability sol...
 
UtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptx
UtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptxUtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptx
UtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptx
 
DevoxxBelgium_StatefulCloud.pptx
DevoxxBelgium_StatefulCloud.pptxDevoxxBelgium_StatefulCloud.pptx
DevoxxBelgium_StatefulCloud.pptx
 
VMworld 2013: Unified Endpoint Management in Scale: What’s New with VMware Ho...
VMworld 2013: Unified Endpoint Management in Scale: What’s New with VMware Ho...VMworld 2013: Unified Endpoint Management in Scale: What’s New with VMware Ho...
VMworld 2013: Unified Endpoint Management in Scale: What’s New with VMware Ho...
 
VMworld 2013: US Air National Guard - DoD Private Cloud Initiative –How Virtu...
VMworld 2013: US Air National Guard - DoD Private Cloud Initiative –How Virtu...VMworld 2013: US Air National Guard - DoD Private Cloud Initiative –How Virtu...
VMworld 2013: US Air National Guard - DoD Private Cloud Initiative –How Virtu...
 
Nagios Conference 2012 - Jason Cook - Nagios and Mod-Gearman
Nagios Conference 2012 - Jason Cook - Nagios and Mod-GearmanNagios Conference 2012 - Jason Cook - Nagios and Mod-Gearman
Nagios Conference 2012 - Jason Cook - Nagios and Mod-Gearman
 
2014-09-15 cloud platform master class
2014-09-15 cloud platform master class2014-09-15 cloud platform master class
2014-09-15 cloud platform master class
 
VMworld 2013: Virtualizing Highly Available SQL Servers
VMworld 2013: Virtualizing Highly Available SQL Servers VMworld 2013: Virtualizing Highly Available SQL Servers
VMworld 2013: Virtualizing Highly Available SQL Servers
 
Government and Education Webinar: Leverage Automation to Improve IT Operations
Government and Education Webinar: Leverage Automation to Improve IT OperationsGovernment and Education Webinar: Leverage Automation to Improve IT Operations
Government and Education Webinar: Leverage Automation to Improve IT Operations
 
VMworld 2013: Demystifying VMware Mirage: Tips and Tricks for Success
VMworld 2013: Demystifying VMware Mirage: Tips and Tricks for Success VMworld 2013: Demystifying VMware Mirage: Tips and Tricks for Success
VMworld 2013: Demystifying VMware Mirage: Tips and Tricks for Success
 
Snap protect se_presentation_v3.0
Snap protect se_presentation_v3.0Snap protect se_presentation_v3.0
Snap protect se_presentation_v3.0
 
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
 
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Dancing While Gaming—Multitasking VMs on Real Devices

  • 1. 2006 JavaOneSM Conference | Session TS-3742 | Dancing While Gaming— Multitasking VMs (MVM) on Real Devices Jae Hyou Lee Yaniv Shani Samsung Electronics Sun Microsystems, Inc. www.samsung.com www.sun.com TS-3742
  • 2. 2006 JavaOneSM Conference | Session TS-3742 | 2 Goal Deeper understanding of Multitasking VM implementation on real devices
  • 3. 2006 JavaOneSM Conference | Session TS-3742 | 3 Project Highlights • A joint collaboration between Samsung Electronics and Sun Microsystems • MVM deployment is based on Sun’s JWC1.1.3 • Deploying most of the MSA JSRs • Tested with hundreds of games and applications from leading content providers
  • 4. 2006 JavaOneSM Conference | Session TS-3742 | 4 Agenda MVM overview MVM in the configuration level MVM in the profile level • The Foreground and Background state • Resource management • Multitasking safety MIDlets in MVM environment Q&A
  • 5. 2006 JavaOneSM Conference | Session TS-3742 | 5 Agenda MVM overview MVM in the configuration level MVM in the profile level • The Foreground and Background state • Resource management • Multitasking safety MIDlets in MVM environment Q&A
  • 6. 2006 JavaOneSM Conference | Session TS-3742 | 6 What Is MVM? • Running multiple applications simultaneously • Java is always on • Favorite applications instantly available MP3 Playing Chatting Gaming
  • 7. 2006 JavaOneSM Conference | Session TS-3742 | 7 MVM Conceptual View Device H/W Operating System Native JVM Task Configuration Level MVM Resource Manager App. Manager AMS JSR JSR JSRJSR Profile Level Multitasking Safety Isolation Model Deployment Guidelines Legacy Content New App States User Experience Resource Policies
  • 8. 2006 JavaOneSM Conference | Session TS-3742 | 8 Agenda MVM overview MVM in the configuration level MVM in the profile level • The Foreground and Background state • Resource management • Multitasking safety MIDlets in MVM environment Q&A
  • 9. 2006 JavaOneSM Conference | Session TS-3742 | 9 Isolates and Tasks Each application runs in its own logical Java Virtual Machine, called an Isolate. Within the JVM, each isolate is represented as a Task. A task consists of one more Java thread of execution.
  • 10. 2006 JavaOneSM Conference | Session TS-3742 | 10 More on Tasks… • All tasks execute in the same single OS task context • All tasks share: • Constant data structure • Runtime support functions • Each task encapsulates non-sharable program state MVM
  • 11. 2006 JavaOneSM Conference | Session TS-3742 | 11 Implementation Details • Each task has a separate, private copy of the static variables of all the loaded Java classes • Static variables are only global to all threads within a particular task Static Variable class A { public static int count; ... } Task 1 class A { public static int count; ... } task 2 MVM • Each task maintains a private copy of ‘count’ • The Class representation is shared
  • 12. 2006 JavaOneSM Conference | Session TS-3742 | 12 Implementation Details Synchronization class A { public static synchronized int open(); } • Synchronization has to be task private • Threads in one task cannot block threads in another task Task 1 Task 2 MVM A.open() A.open() A.open() A.open() Blocking Threads Across Tasks Isn’t Allowed
  • 13. 2006 JavaOneSM Conference | Session TS-3742 | 13 Resource Management • The JVM is responsible for CPU time and memory resources in order to ensure that all tasks get their “fair” share • Other resources, such as network bandwidth and communication ports are managed by the profile layer
  • 14. 2006 JavaOneSM Conference | Session TS-3742 | 14 Resource Management—Scheduling • Tasks and thread are scheduled by the JVM • Fair scheduling algorithm is used for task scheduling in order to prevent one task from taking disproportionate CPU time • The ‘Isolate’ class offers a set of APIs to modify the priority levels for each task ` Task 2 Scheduler MVM Task 1 Active Thread MVM
  • 15. 2006 JavaOneSM Conference | Session TS-3742 | 15 Resource Management—Memory • All tasks allocations are conducted from the same global heap region • The virtual machine has a bookkeeping mechanism that accounts for each task total heap memory consumption • The JVM injects OutOfMemoryError as needed to inform tasks that heap space has become scarce
  • 16. 2006 JavaOneSM Conference | Session TS-3742 | 16 Agenda MVM overview MVM in the configuration level MVM in the profile level • The Foreground and Background state • Resource management • Multitasking safety MIDlets in MVM environment Q&A
  • 17. 2006 JavaOneSM Conference | Session TS-3742 | 17 New MIDlet State in MVM • An application is said to be in the Foreground when: • Its displayable controls the display • It handles event from the user input mechanism • Only one MIDlet can execute in the Foreground at a time Foreground MIDlet
  • 18. 2006 JavaOneSM Conference | Session TS-3742 | 18 New MIDlet State in MVM Background MIDlet • An application is in the Background when: • Its displayable does not control the display • It does not handle the user inputs mechanism • Zero or more MIDlets can execute in the Background at a time
  • 19. 2006 JavaOneSM Conference | Session TS-3742 | 19 The Application Manager • A resident MIDIet • Executed from power on • Lists the running applications • A fast way to switch between running MIDlets • Display background MIDIets alerts
  • 20. 2006 JavaOneSM Conference | Session TS-3742 | 20 Switching a MIDlet to the Background (1/3) • Upon a short ‘Hot’ key press the foreground MIDlet will be placed in the background and main device menu will be displayed Short ‘Hot’ Key Press Short ‘Hot’ Key
  • 21. 2006 JavaOneSM Conference | Session TS-3742 | 21 Switching a MIDlet to the Background (2/3) • Upon a long ‘Hot’ key press the foreground MIDlet will be placed in the background and the ‘Application manager’ dialog will be displayed Long ‘Hot’ Key Long ‘Hot’ Key
  • 22. 2006 JavaOneSM Conference | Session TS-3742 | 22 Switching a MIDlet to the Background (3/3) Invoking Display.setCurrent(null) • Upon calling setCurrent(null) the MIDlet will be placed in the background and the ‘idle’ screen of the device will be displayed Display.setCurrent(null)
  • 23. 2006 JavaOneSM Conference | Session TS-3742 | 23 Interrupting the User • Background MIDlet calls Display.setCurrent(alert) • Background MIDlet tries to access a protected API and a security dialog is prompted • Noteworthy event occurred in the background • e.g., Incoming IM while playing a game
  • 24. 2006 JavaOneSM Conference | Session TS-3742 | 24 DEMO User Experience Demonstration
  • 25. 2006 JavaOneSM Conference | Session TS-3742 | 25 Agenda MVM overview MVM in the configuration level MVM in the profile level • The Foreground and Background state • Resource management • Multitasking safety MIDlets in MVM environment Q&A
  • 26. 2006 JavaOneSM Conference | Session TS-3742 | 26 Managing Resources • In a single-tasking environment, the MIDlet has access to all of the available resources • In a multitasking environment, MIDlets have to compete for available resources
  • 27. 2006 JavaOneSM Conference | Session TS-3742 | 27 Managing Resources • Mechanisms • Reservation • Quota • Revocation • Policies • Fixed partition • Open for competition • Special cases
  • 28. 2006 JavaOneSM Conference | Session TS-3742 | 28 Resource Management Mechanisms • A reservation mechanism sets aside a certain amount of a resource for a MIDlet and keeps it available for that MIDlet and that MIDlet alone Reservation
  • 29. 2006 JavaOneSM Conference | Session TS-3742 | 29 Resource Management Mechanisms • A quota mechanism permits a MIDlet to allocate up to a certain amount of a resource; if the MIDlet attempts to allocate more resources than its quota, the attempt fails, even if resources are actually available on the system Quota
  • 30. 2006 JavaOneSM Conference | Session TS-3742 | 30 Resource Management Mechanisms • The system can revoke a resource from a MIDlet and give it to another MIDlet • Resource revocation examples: • CPU cycles • Display access • Audio playback • Resource revocation doesn’t always have a dramatic effect on the MIDlet’s execution Revocation
  • 31. 2006 JavaOneSM Conference | Session TS-3742 | 31 Resource Management Policies • Initial amount of resources are reserved before MIDlet launch • Resource availability validation during MIDlet’s startup • Ensure consistent MIDlet behavior Fixed Partition
  • 32. 2006 JavaOneSM Conference | Session TS-3742 | 32 Resource Management Policies • No reservation • Resource are acquired and reclaimed at runtime • May lead to unpredictable behavior Open for Competition
  • 33. 2006 JavaOneSM Conference | Session TS-3742 | 33 Special Resource Management Policies • Only the Foreground can access the LCD display and receive key inputs events • The current displayable of a Background MIDlet is still updated Note: vibrate() ,flashBacklight() and tone playing aren’t honored when invoked from a Background MIDlet LCD Display
  • 34. 2006 JavaOneSM Conference | Session TS-3742 | 34 Sound (1/2) Special Resource Management Policies • Foreground MIDlets are assigned physical player that can access the audio device resource • Background MIDlets are assigned a logical player that only maintains the audio state • Upon foreground switch the player state is changed automatically Logical Player Physical Player 1 Logical Player Physical Player 2 Foreground Switch
  • 35. 2006 JavaOneSM Conference | Session TS-3742 | 35 Special Resource Management Policies • Unique JAD file property to lock audio resources • Allows a background MIDlet to be audible • Useful for media players (e.g., the MP3 player, radio, etc.) Sound (2/2) 1 Logical Player Physical Player 2 Logical Player Physical Player 1 Foreground Switch
  • 36. 2006 JavaOneSM Conference | Session TS-3742 | 36 A Full Resource Policy Matrix Fixed Open Special Memory X X CPU X X File Descriptor X X Socket X X Display X Sound X X Bluetooth X Location X PIM X
  • 37. 2006 JavaOneSM Conference | Session TS-3742 | 37 Guidelines for Resource Policy Selection • Resource policy definition relies on the underlying platform capabilities and requirements • Fixed partition policy should be used for fundamental resources that are required by the majority of the applications (e.g., memory, file, socket) • Open policy should be used resources that are used by specific MIDlets and have limited availability (e.g., Bluetooth, location) • Display and sound requires special handling
  • 38. 2006 JavaOneSM Conference | Session TS-3742 | 38 DEMO Resource Policy Demonstration
  • 39. 2006 JavaOneSM Conference | Session TS-3742 | 39 Agenda MVM overview MVM in the configuration level MVM in the profile level • The Foreground and Background state • Resource management • Multitasking safety MIDlets in MVM environment Q&A
  • 40. 2006 JavaOneSM Conference | Session TS-3742 | 40 Multitasking Safety • The native JVM task can run native code for any task, hence the code must be made aware of the task on whose behalf it is being called and possibly allocating resources • When the task context is established, the code is considered multitasking safe • Sun’s JWC software is multitasking safe
  • 41. 2006 JavaOneSM Conference | Session TS-3742 | 41 Multitasking Safety Implementation Guidelines • In some cases a deployment of a profile to MVM environment requires additional development in order that the profile will execute properly Foreground Switch Blocking Threads Across Tasks Isn’t Allowed
  • 42. 2006 JavaOneSM Conference | Session TS-3742 | 42 Multitasking Safety • At Java level, each task has a separate, private copy of the static variables of all the loaded Java classes • This is handled internally by the MVM • Native code often has global data • Native data is shared across all tasks! • Global native data needs to be replicated for each task • Held as a field of a Java object • Proper handling for singleton depends on whether it is meant be used on a per-task basis (the default behavior for MVM), or by the entire system Static and Global Variable
  • 43. 2006 JavaOneSM Conference | Session TS-3742 | 43 Agenda MVM overview MVM in the configuration level MVM in the profile level • The Foreground and Background state • Resource management • Multitasking safety MIDlets in MVM environment Q&A
  • 44. 2006 JavaOneSM Conference | Session TS-3742 | 44 MIDlet Guidelines • MIDlets developed on top of ‘Canvas’ class will receive the following notifications: • Canvas.hideNotify(): When switching to background • Canvas.showNotify(): When returning to foreground • MIDP2.0 spec. doesn’t offer APIs for MIDlet that doesn’t use the ‘Canvas’ class facilities MIDlet State Detection
  • 45. 2006 JavaOneSM Conference | Session TS-3742 | 45 MIDlet Guidelines • Switching to background does not pause a MIDlet by default • Legacy content handling • Some MIDlets (e.g., legacy games) will not run correctly in the background • A new JADfile property can request that the MIDlet be paused when switched to background In the Background, Am I Paused?
  • 46. 2006 JavaOneSM Conference | Session TS-3742 | 46 MIDlet State Detection • Most of the games should be suspended in background • Player may be inadvertently killed • Free up resource that aren’t in use • No need to continue painting when nobody sees the results • Make sure to attract the users attention when something interesting happens in the background How to Behave While Executing in Background?
  • 47. 2006 JavaOneSM Conference | Session TS-3742 | 47 MIDlet Guidelines • Return resources when you are done with them, don’t wait for destroyApp() • Expect and detect failures in resource acquisition • Help the users to overcome resource acquisition failure • Expect to see new JAD file properties for resource policy indication (heap size, special sound policy, etc.) Resource Awareness
  • 48. 2006 JavaOneSM Conference | Session TS-3742 | 48 Boot-time MIDlets • Launch in the background at boot time • Bring to foreground upon arrival of incoming event • Examples: • MMS, SMS, IM, Mail clients • Stock, weather, news
  • 49. 2006 JavaOneSM Conference | Session TS-3742 | 49 Summary • MVM in the configuration level: • Isolation Model • JVM executes in a single native task context • MVM in the profile level • Foreground and Background state • Resource management and policy • User experience • Multitasking safety • MIDlets in MVM environment
  • 50. 2006 JavaOneSM Conference | Session TS-3742 | 50 Agenda MVM overview MVM in the configuration level MVM in the profile level • The Foreground and Background state • Resource management • Multitasking safety MIDlets in MVM environment Q&A
  • 51. 2006 JavaOneSM Conference | Session TS-3742 | 51 Q&A
  • 52. 2006 JavaOneSM Conference | Session TS-3742 | Dancing While Gaming— Multitasking VMs (MVM) on Real Devices Jae Hyou Lee Yaniv Shani Samsung Electronics Sun Microsystems, Inc. www.samsung.com www.sun.com TS-3742