a real time extension to the android platform igor kalkov
play

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


  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

  2. Introduction  Mobile platform by Open Handset Alliance - Supervised by Google - Open-sourced under Apache 2.0 license  Android software stack: Applications  Applications • Stock & user applications Application Framework  Application framework Runtime • Services & system managers Libraries  Android runtime • Dalvik virtual machine Linux Kernel • SSL, media, SQLite database  Adapted Linux kernel • Hardware drivers, memory & process management 2 / 15

  3. 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 3 / 15

  4. Related Work Several proposed approaches:  4 / 15

  5. Approach Applications System Applications 3rd Party Applications  Application Framework Extended Activity Manager Notification - Reliable execution of RT apps Activity Manager Package Manager Manager … - Bypassing OOM process killer Resource Manager Window Manager  Modified Dalvik VM Libraries Android Runtime - Encapsulated priority selection Graphics SQLite Core Libraries - Explicit memory management … Dalvik Virtual SSL Machine  Improved Linux kernel v2.6.29 Linux Kernel - Patched with PREEMPT_RT Power Process Hardware Drivers Management Management - Enabled priority scheduling … Memory Binder (IPC) Driver Management 5 / 15

  6. 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 6 / 15

  7. 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 7 / 15

  8. Memory Management (2) 8 / 15

  9. 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 instantiate :ServiceRT set adj_p Normal priority change priority Real-time priority terminate 9 / 15

  10. 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 10 / 15

  11. Latencies (1)  System state: idle  𝑢 𝑄 = 5 𝑛𝑡  𝑈 = 20 𝑡  Priorities: 120 (default) vs. 40 (real-time) Non-RT Process RT Process 25 25 20 20 Latency (ms) Latency (ms) 15 15 10 10 5 5 0 0 0 5000 10000 15000 20000 0 5000 10000 15000 20000 Execution Time (ms) Execution Time (ms) 11 / 15

  12. Latencies (2)  System state: under load  𝑢 𝑄 = 5 𝑛𝑡  𝑈 = 20 𝑡  Priorities: 120 (default) vs. 40 (real-time) Non-RT Process RT Process 2449 7780 1000 10 800 8 Latency (ms) Latency (ms) 600 6 400 4 200 2 0 0 0 5000 10000 15000 20000 0 5000 10000 15000 20000 Execution Time (ms) Execution Time (ms) 12 / 15

  13. Evaluation: Memory Management Automatic GC Manual Freeing  Test 2: Continuous data receiving 3000 Memory Footprint (kB) 2900 - Over a 54 Mbit Wi-Fi connection 2800 - Count: 2000 packets 2700 2600 - Size: ~ 1 kB each 2500 - Can be released after processing 2400 2300 2200 0 10 20 30 40 50 60 Time (s)  Test 3: Explicit object deallocation Automatic GC Manual Freeing Avg. Freeing Time (ms) 120 - Allocate an object of a given size - Free it immediately 80 - Measure the elapsed time 40 - Calculate average of 10 cycles - For different sizes: 1 Byte to 8 MB 0 0 2000 4000 6000 8000 Object Size (kB) 13 / 15

  14. 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 14 / 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 15 / 15

  16. Thank you for your attention! Questions / Comments?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend