A Real-time Extension to the Android Platform Igor Kalkov, Dominik - - PowerPoint PPT Presentation

a real time extension to the android platform igor kalkov
SMART_READER_LITE
LIVE PREVIEW

A Real-time Extension to the Android Platform Igor Kalkov, Dominik - - PowerPoint PPT Presentation

JTRES 2012 A Real-time Extension to the Android Platform Igor Kalkov, Dominik Franke, John F. Schommer, Stefan Kowalewski 24-26 October 2012 Copenhagen, Denmark Introduction Mobile platform by Open Handset Alliance - Supervised by


slide-1
SLIDE 1

JTRES 2012

A Real-time Extension to the Android Platform

Igor Kalkov, Dominik Franke, John F. Schommer, Stefan Kowalewski

24-26 October 2012 Copenhagen, Denmark

slide-2
SLIDE 2

2 / 15

Introduction

  • Mobile platform by Open Handset Alliance
  • Supervised by Google
  • Open-sourced under Apache 2.0 license
  • Android software stack:

 Applications

  • Stock & user applications

 Application framework

  • Services & system managers

 Android runtime

  • Dalvik virtual machine
  • SSL, media, SQLite database

 Adapted Linux kernel

  • Hardware drivers, memory & process management

Runtime Libraries Application Framework Applications Linux Kernel

slide-3
SLIDE 3

3 / 15

Motivation

  • Real-time support expands the field of application
  • Opening safety- & time-critical domains
  • In-field monitoring, controlling platform for home automation
  • Better core functionalities: speech or video processing
  • Goals
  • Possibility of serving real-time requests
  • Keeping original functionality / backward compatibility
  • Wide range of compatible hardware platforms
  • Smartphones, tablets, OMAP hardware
  • Further applications: eReaders, TVs, Nanosatellites
slide-4
SLIDE 4

4 / 15

Related Work

  • Several proposed approaches:
slide-5
SLIDE 5

5 / 15

Approach

  • Extended Activity Manager
  • Reliable execution of RT apps
  • Bypassing OOM process killer
  • Modified Dalvik VM
  • Encapsulated priority selection
  • Explicit memory management
  • Improved Linux kernel v2.6.29
  • Patched with PREEMPT_RT
  • Enabled priority scheduling

Applications

System Applications 3rd Party Applications

Application Framework

Activity Manager Notification Manager Package Manager Resource Manager

Window Manager Graphics SQLite

SSL Core Libraries Dalvik Virtual Machine Power Management Process Management

Binder (IPC) Driver

Linux Kernel Libraries Android Runtime

Hardware Drivers Memory Management

slide-6
SLIDE 6

6 / 15

Activity Manager

  • Internal process importance
  • Depends on the application class (back- / foreground)
  • Reflected in OOM adjustment values 𝑏𝑒𝑘𝑞
  • Built-in OOM process killer
  • Killing “unimportant” processes first
  • Memory thresholds 𝑛𝑓𝑛𝑢 and corresponding levels 𝑏𝑒𝑘𝑢
  • Example with 𝑛𝑓𝑛3 = 20 𝑁𝐶 and 𝑏𝑒𝑘3 = 7
  • Terminate processes with 𝑏𝑒𝑘𝑞 ≥ 7 on 𝑛𝑓𝑛𝑔𝑠𝑓𝑓 ≤ 20 𝑁𝐶
  • RT processes must get lowest possible 𝑏𝑒𝑘𝑞 values
slide-7
SLIDE 7

7 / 15

Memory Management (1)

  • Advantages:
  • Smart low memory process killer
  • Process-independent GC (Dalvik VM)
  • Disadvantages:
  • Mark-and-sweep algorithm
  • Execution of all threads is suspended (up to 200 ms)
  • No reliable prediction of process behavior
  • Explicit allocation control
slide-8
SLIDE 8

8 / 15

Memory Management (2)

slide-9
SLIDE 9

9 / 15

Programming Interface

  • Introducing new class ServiceRT.java
  • Extends Android’s native Service.java class
  • API for priority selection for own process
  • API for explicit memory deallocation

Android OS Linux kernel :ServiceRT instantiate set adj_p change priority

Real-time priority Normal priority

terminate

slide-10
SLIDE 10

10 / 15

Evaluation

  • Testing device: HTC Dream / Google G1
  • Background service based on ServiceRT class
  • Test 1: Periodic execution
  • Compare scheduled & actual execution time
  • Period time 𝑢𝑄 = 1 𝑛𝑡 to 𝑢𝑄 = 1 𝑡
  • Running time 𝑈 = 20 𝑡 to 𝑈 = 1 ℎ
  • Different process priorities
  • Idle system or high CPU load
slide-11
SLIDE 11

11 / 15

Latencies (1)

  • System state: idle
  • 𝑢𝑄 = 5 𝑛𝑡
  • 𝑈 = 20 𝑡
  • Priorities: 120 (default) vs. 40 (real-time)

5 10 15 20 25 5000 10000 15000 20000

Latency (ms)

Execution Time (ms)

RT Process

5 10 15 20 25 5000 10000 15000 20000

Latency (ms)

Execution Time (ms)

Non-RT Process

slide-12
SLIDE 12

12 / 15

Latencies (2)

  • System state: under load
  • 𝑢𝑄 = 5 𝑛𝑡
  • 𝑈 = 20 𝑡
  • Priorities: 120 (default) vs. 40 (real-time)

200 400 600 800 1000 5000 10000 15000 20000

Latency (ms)

Execution Time (ms)

Non-RT Process

7780 2449

2 4 6 8 10 5000 10000 15000 20000

Latency (ms)

Execution Time (ms)

RT Process

slide-13
SLIDE 13

13 / 15

Evaluation: Memory Management

  • Test 2: Continuous data receiving
  • Over a 54 Mbit Wi-Fi connection
  • Count: 2000 packets
  • Size: ~ 1 kB each
  • Can be released after processing

2200 2300 2400 2500 2600 2700 2800 2900 3000 10 20 30 40 50 60

Memory Footprint (kB) Time (s) Automatic GC Manual Freeing

40 80 120 2000 4000 6000 8000

  • Avg. Freeing Time (ms)

Object Size (kB) Automatic GC Manual Freeing

  • Test 3: Explicit object deallocation
  • Allocate an object of a given size
  • Free it immediately
  • Measure the elapsed time
  • Calculate average of 10 cycles
  • For different sizes: 1 Byte to 8 MB
slide-14
SLIDE 14

14 / 15

Conclusion

  • New approach
  • Patched Linux kernel & Android components
  • Handling of OOM adjustment values
  • Use Linux real-time priorities for Android applications
  • Explicit memory management
  • Evaluation
  • Avoiding undesired invocations of the GC
  • Scheduling latency < 2 ms for real-time processes
  • BUT: explicit memory management is not enough
  • Dangling pointers, background allocations
slide-15
SLIDE 15

15 / 15

Future Work

  • Automatic, non-blocking real-time GC algorithms
  • M. Schoeberl, W. Puffitsch

“Nonblocking Real-Time Garbage Collection”

  • Y. Levanoni, E. Petrank

“On-The-Fly Reference-Counting Garbage Collector for Java“

  • Using RT-Linux high resolution timer for periodic tasks
  • Better scheduling latencies (WC ≈ 500 us)
  • More about the project will be available soon under

https://git.embedded.rwth-aachen.de/rtandroid

slide-16
SLIDE 16

Thank you for your attention!

Questions / Comments?