<<

23-Oct(Fri) , 2009

ZygoteZygote AnatomyAnatomy BasedBased onon PrelinkPrelink && PreloadPreload forfor AndroidAndroid PlatformPlatform

4th Korea Android Seminar

GeunSik Lim [email protected] http://blog.naver.com/invain

4th Korea Android Seminar 1/53 Agenda

1. Dynamic Linking & Static Linking 2. Fundamentals 3. Understanding Preload 4. Custom (=Android Prelink) 5. Zygote Walkthrough 6. Relation between process and thread by Zygote

4th Korea Android Seminar 2/53 Main Keywords in This Session

ynami D g nkin Li fetch Pre Static k Prelin Linking Custom Linker for Android d Prerea Zygote Prel oad mic Dyna Prefork ing Load

4th Korea Android Seminar 3/53 Location of Linker in FOSS World

4th Korea Android Seminar 4/53 Static Linking

• Static linking avoids dependency problems. (-static)

• In general cases, static linking can result in a performance improvement.

• Static linking can also allow the application to be contained in a single file, simplifying distribution and installation.

• In static linking, the size of the executable becomes greater than in dynamic linking, as the code is stored within the executable rather than in separate files.

4th Korea Android Seminar 5/53 Dynamic Linking

• Libraries can be integrated into a program once by a linker. Dynamic linking has advantages in code size and management. ( -dynamic)

• But, every time a program is run, the needs to find the relevant libraries.

• Because 1) the libraries can move around in memory, this causes a performance penalty, 2) and the more libraries that need to be resolved, the greater the penalty.

4th Korea Android Seminar 6/53 with

• Programming Interface : dlopen( ), dlsym( ), dlclose( ), dlerror( ) • Load the math library, and print the cosine of 2.0

#include stdio.h , stdlib.h , dlfcn.h int main (int argc, char **argv) { void *handle; double (*cosine)(double); char *error;

handle = dlopen("libm.so", RTLD_LAZY); if (!handle) { fprintf(stderr, "%s\n", dlerror()); exit(EXIT_FAILURE); }

dlerror(); /* Clear any existing error */ *(void **) (&cosine) = dlsym(handle, "cos");

if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); exit(EXIT_FAILURE); }

printf(“Consine is %f\n", (*cosine)(2.0)); dlclose(handle); exit(EXIT_SUCCESS); }

4th Korea Android Seminar 7/53 Static vs. dynamic

Static

Linux libraries Dynamic Loading Shared

Dynamic Linking

Program X Program Y Static libraries Static libraries

Static linking ( *.a ) ( *.a ) Static linking At compile-time (init daemon of Android) Program X Program Y

Shared libraries Dynamic linking ( *.so )

Dynamic linking Dynamic Of shared libraries At run-time 4th Korea Android Seminar 8/53 Source Compile Process

cpp0 PreProcesser cc1 C Compiler Assembler ld or collect2 Hello.c Linker C Source Hello.i ProProcess Result Hello.s Assembly File Hello.o Hello ELF --save-temps

ADT JAVA Compiler DX Utility with .XML & .ARSC Eclipse .java (Source Code) .class file (Byte Code) .dex like exe on Dalvik VM .apk Decompiler (Interpreter) (e.g: Decafe , DJ Java)

4th Korea Android Seminar 9/53 Preload

• Files of more frequently-used programs are, during a computer's spare time, loaded into memory.

• This results in faster (speed up) application startup times as less data needs to be fetched from disk.

/lib/libc.so.6 /lib/libcom_err.so.2 /lib/libcrypt.so.1 Preload /lib/libcrypto.so.6 /lib/libdb-4.3.so /lib/libdbus-1.so.3 /lib/libdl.so.2 /lib/libexpat.so.0 /lib/libglib-2.0.so.0 /lib/libgmodule-2.0.so.0 /lib/libgobject-2.0.so.0 /lib/libgthread-2.0.so.0 . . . Below Omission . . . rams used prog frequently-

4th Korea Android Seminar 10/5 3 Readahead Daemon for Preload

• The readahead reads the contents of a list of files into memory, which causes them to be read from cache when they are actually needed. Its goal is to speed up the boot process.

• e.g) Readahead daemon for Linux distribution - An adaptive prefetching daemon - http://sourceforge.net/projects/preload/ #> /usr/sbin/readahead `cat /etc/readahead.early.files` & - A list of files cached in the memory

lsof / | grep -v "^₩(lsof₩|grep₩)" | awk '{ print $4 " " $9 }' | grep ^mem ₩ | awk '{ print $2 }' |grep -v "^.₩(var₩|tmp₩|home₩|root₩)" | grep ^[/] | sort -u

if (fd >= 0) { readahead(fd, offset, length); close (fd); }

4th Korea Android Seminar 11/53 What is Prelink?

• A tool designed to speed up dynamic linking of ELF programs. (e.g: ELF shared libraries and ELF dynamically linked binaries)

• To speed up a system by reducing the time a program needs to begin.

• A FOSS is written by Jakub Jelinek of Red Hat. F11#> svn checkout http://sourceware.org/svn/prelink/trunk prelink

• Process on Mac OS X is called "prebinding".

4th Korea Android Seminar 12/53 Merits of Prelink

needs for their at startup significantly decreases.

• The run-time memory consumption decreases too according to fewer relocations. ☎ Prelinked system fedora11$> LD_DEBUG=statistics firefox 2>&1 | sed ’s/ˆ *//’ 25733: runtime linker statistics: 25733: total startup time in dynamic loader: 5533696 clock cycles 25733: time needed for relocation: 1941529 clock cycles (35.0%) 25733: number of relocations: 0 25733: number of relocations from cache: 2066 25733: number of relative relocations: 0 25733: time needed to load objects: 3217736 clock cycles (58.1%) 25733: runtime linker statistics: 25733: final number of relocations: 0 25733: final number of relocations from cache: 2066

4th Korea Android Seminar 13/53 Prelink Map

Application Process Global Dynamic Loader Linkage Table Offset Table PLT Slot Got Entry dl_runtime_resolve JMP GOT[1] GOT[1] dl_runtime_resolve {{ JMP GOT[2] GOT[2] ...... JMP GOT[3] GOT[3] . . . ④ call func_a(); . . . call func_a(); } ... JMP GOT[4] GOT[4] ③ } ...... ② ... call func_b(); JMP GOT[5] GOT[5] call func_b();... ① ... JMP GOT[6] GOT[6] ... Symbol Table call func_c();... call func_c(); JMP GOT[7] GOT[7] ... Lazy Binding ...... func_a ...... ⑦ ...... func_a call func_d();... 0x12345678 ... call func_d();...... JMP GOT[N-2] GOT[N-2] ...... Symbol JMP GOT[N-1] GOT[N-1] func_bfunc_b ...Lookup JMP GOT[N] GOT[N] ⑧ ... ⑤ func_cfunc_c Update GOT LookUp Address ...... (Relocation) ⑥ ss of e Addre Absolut bole 4th Korea Android Seminar Sym 14/53 Prelink on X86 Desktop 1/2 prelink-no#> yum -y install prelink ( ubuntu#> apt-get –y install prelink ) prelink-no#> prelink ./firefox prelink-yes#> time LD_DEBUG=statistics DISPLAY= LD_LIBRARY_PATH=. ./firefox real 7m0.261s user 4m0.026s sys 1m0.082s prelink-yes#> prelink --undo ./firefox prelink-no#> time LD_DEBUG=statistics DISPLAY= LD_LIBRARY_PATH=. ./firefox Speed Up real 9m1.342s user 5m6.024s sys 1m5.052s

4th Korea Android Seminar 15/53 Prelink on X86 Desktop 2/2

• Appended Section Headers After Prelink : .gnu_liblist , .gnu_conflict, .gnu_prelink_undo

4th Korea Android Seminar 16/53 Why do you need Prelink?

• prelink reduces this penalty by using the system's dynamic linker to reversibly perform this linking in advance by relocating.

• Afterward, the program only needs to spend time finding the relevant libraries on being run if, for some reason (perhaps an upgrade), the libraries have changed since being prelinked.

• In Android Platform, The need for Almost all the local symbols ( 80-90 % of the symbols in .rel.dyn and .rel.plt) and it gives much quicker performance.

In Summary, In order to reduce size and speed up loading.

4th Korea Android Seminar 17/53 F11#> export LANG=C F11#> man 2 dlopen F11#> man 3 exec Diff Between Prelink and Preload in Mobile

• Prelink for prelinked binary model for fork and exec model. • Preload for non-prelinked binary execution model for fork and dlopen model. • Hybrid for pre-linked binary execution model for fork and dlopen model. Zygote

ile ob M r Fo

Ref) Hybrid related Paper : Performance Characterization of Prelinking and Preloading for Embedded Systems 4th Korea Android Seminar 18/53 Memory Layout of Pre-linked Libraries

Prelinked libraries can only be loaded at the very specific address they have been prelinked to (during the build process). The list of prelinked system libraries and their corresponding virtual memory address is found in the below file.

./build/core/prelink-linux-arm.map # 0xC0000000 - 0xFFFFFFFF Kernel # 0xB0100000 - 0xBFFFFFFF Thread 0 Stack # 0xB0000000 - 0xB00FFFFF Linker # 0xA0000000 - 0xBFFFFFFF Prelinked System Libraries # 0x90000000 - 0x9FFFFFFF Prelinked App Libraries # 0x80000000 - 0x8FFFFFFF Non-prelinked Libraries # 0x40000000 - 0x7FFFFFFF mmap'd stuff # 0x10000000 - 0x3FFFFFFF Thread Stacks # 0x00000000 - 0x0FFFFFFF .text / .data / heap • #define PRELINK_MIN 0x90000000 • #define PRELINK_MAX 0xB0000000

4th Korea Android Seminar 19/53 Prelinked System Libraries

01. Core System Libraries (libdl, libc, libstdc++, libm, liblog, libcutils, libthread_db, libz, libevent, libssl, libcrypto, libsysutils) 02. Bluetooth (liba2dp, audio, input, libhcid, libbluedroid, libbluetooth, libdbus) 03. Extended system libraries ( libril, libreference-ril, libwpa_client, libnetutils) 04. Core dalvik runtime support (libicuuc, libicui18n, libandroid-runtime, libnativehelper, libdvm-ARM, libdvm) 05. Graphics ( libpixelflinger, libcorecg, libsurfaceflinger, libagl, libGLESv1_CM, libGLESv2, libOpenVG_CM, libOpenVGU_CM, libEGL, libexif, libui, libsgl) 06. Audio 07. Assorted System libraries 08. PV opencore libraries 09. Opencore hardware support 10. PV libraries

4th Korea Android Seminar 20/53 Prelinked Application Libraries

01. libraries for specific apps or temporary ( libcam_ipl, libwbxml, libwbxml_jni, libxml2wbxml, libaes, libdrm1, libdrm1_jni, libwapcore, libstreetview, libwapbrowsertest, libminiglobe, libearth, libembunit, libneon, and so on)

4th Korea Android Seminar 21/53 How to use Prelink Module for Android 1/2

• It should be updated each time that a new system library is added to the system.

• The prelink step happens at build time, and uses the 'soslim' and 'apriori‘ tools: 1. 'soslim(./build/tools/soslim/*)' is used to find symbols in an executable ELF file and generate a list that can be passed to 'apriori'.

2. 'apriori(./build/tools/apriori/*)' is the real prelink tool which removes relocations from the shared object, however, it must be given a list of symbols to remove from the file.

4th Korea Android Seminar 22/53 Difference between Prelink and Android Prelink?

• Android Prelink is a custom pre-linking tool. • The same thing than GNU-style hash with minor modifications. (e.g. forcing power-of-2 table sizes to avoid the horribly slow module operation on ARM during lookups, plus selecting smaller table sizes by default. Æ Q: GNU LD 2.17.50.0.X has the support of GNU-style hash. What is the benefit of this approach??? • Custom pre-linking tool means that remove the need for most of the symbol lookups.

/* NetBSD's Hash Table */ int hash_lookup(Elf *elf, Elf_Data *hash, Elf_Data *symtab, Elf_Data *symstr, const char *symname) { Elf32_Word *hash_data = (Elf32_Word *)hash->d_buf; Elf32_Word index; Elf32_Word nbuckets = *hash_data++; Elf32_Word *buckets = ++hash_data; Elf32_Word *chains = hash_data + nbuckets; index = buckets[elf_hash(symname) % nbuckets]; while (index != STN_UNDEF && strcmp((char *)symstr->d_buf +((Elf32_Sym *)symtab->d_buf)[index].st_name, symname)) { index = chains[index]; } return index; } 4th Korea Android Seminar 23/53 How to use Prelink Module for Android 2/2

• By default, these tools are only used to remove internal symbols from libraries, though they have been designed to allow more aggressive optimizations . (e.g. 'global' prelinking and symbol stripping, which prevent replacing individual system libraries though).

• You can disable prelinking at build time by modifying your Android.mk with a line like:

LOCAL_PRELINK_MODULE := false

(e.g. ./bionic/libc/Android.mk , ./bionic/linker/Android.mk, and so on )

4th Korea Android Seminar 24/53 Prelink Module for shared libraries

• Standard rules for building a normal shared library. • Additional inputs from base_rules.make: None. • LOCAL_PRELINK_MODULE will be set for you. • Android Prelink tool means Android Toolchain and Bionic libc

Optimization of dynamic libraries : Prelink (pre-connected) technology

./build/core/shared_library.mk

4th Korea Android Seminar 25/53 What is Zygote ?

The "zygote" is a preforked simple process that the system keeps around that makes new application startup faster. Å By Dan Morrill

It sits idle in a neutral state (that is, "unfertilized" by a specific application) until it's needed, at which point the system instructs it to exec() the appropriate application.

A new zygote process is then started up in the background to replace the old, waiting for the next process to start.

4th Korea Android Seminar 26/53 What is Zygote’s Role?

Zygote start Dalvik VM and start system server. It’s the most important process to speed up.The source is in ./device/servers/app.

You absolutely can not create any threads in zygote, since it will be forking (without exec) from itself. Å By Dianne Hackborn

$> chrome “--renderer-cmd-prefix=gdb –args” Æ Using the --renderer-cmd-prefix option bypasses the zygote launcher.

4th Korea Android Seminar 27/53 Zygote Anatomy for Android Platform

Fork new VM (Dalvik) libc By init (static) Runtime

Zygote

Zygote

Prelinked Prelinked Libstdc++ libc

Surface Flinger Activie Manager Package Manager WindowManager . . . Audio System Flinger Dalvik Dalvik Server System System Server Server 4th Korea Android Seminar 28/53 Zygote’s location in boot sequence

• System Server starts the core Android services. e.g) ActivityManager, WindowManager, PackageManager, etc init Linux

daemons Zygote Runtime

dalvik Service Manager Core Engine System Server Registration (binder) Surface Manager

Audio Manager

Core Services Telephony BlueTooth ......

Active Manager Package Manager Service Manager

4th Korea Android Seminar 29/53 Start-up Walkthrough

It all starts with init… Similar to most Linux-based systems at startup, the bootloader loads the Linux kernel and starts the init process.

Init

Linux Kernel

4th Korea Android Seminar 30/53 Start-up Walkthrough

Init starts Linux daemons, including: 1. USB Daemon to manage USB connections 2. Android Debug Bridge to manage ADB connections 3. Debugger Daemon to manage debug processes requests (dump memory, etc.) 4. Radio Interface Layer Daemon to manage communication with the radio.

usbd adbd debuggerd rild

init

4th Korea Android Seminar 31/53 Start-up Walkthrough

Init process starts the zygote process: 1. A nascent process which initializes a Dalvik VM instance. Loads classes and listens on socket for requests to spawn VMs. (Load preload classes: device/java/android/preloaded-classes) 2. Forks on request to create VM instances for managed processes. (Load preload resources.) 3. Copy-on-write to maximize re-use and minimize footprint.

usbd adbd debuggerd daemons Zygote

Init

device/java/android/com/android/internal/os/ZygoteInit.java

4th Korea Android Seminar 32/53 Start-up Walkthrough

• Pre-loaded Class objects do live in the Zygote heap. • Classes(1,167) which are preloaded by com.android.internal.os.ZygoteInit. • Screenshot using LogCat ( e.g: Log.d , Log.e , Log.i , Log.v , Log.w )

07-13 19:52:44.667: INFO/Zygote(563): ...preloaded 15 resources in 23ms. 07-13 19:52:44.727: DEBUG/dalvikvm(563): GC freed 117 objects / 8416 bytes in 52ms 07-13 19:52:44.786: DEBUG/dalvikvm(563): GC freed 205 objects / 8064 bytes in 47ms 07-13 19:52:44.852: DEBUG/dalvikvm(563): GC freed 36 objects / 1384 bytes in 50ms s)) uurrccees 07-13 19:52:44.846: INFO/dalvikvm(563): Splitting out new zygote heap RReessoo 07-13 19:52:44.876: INFO/dalvikvm(563): System server process 582 hasss ((been created llasasssee 07-13 19:52:44.876: INFO/Zygote(563): Accepting commandg CC socket connections adadiinng 07-13 19:52:44.917: INFO/jdwp(582):Prree receivedlloo file descriptor 19 from ADB 07-13 19:52:45.016: DEBUG/dalvikvm(582):P Trying to load lib /system/lib/libandroid_servers.so 0x0 07-13 19:52:45.186: DEBUG/dalvikvm(582): Added shared lib /system/lib/libandroid_servers.so 0x0 07-13 19:52:45.206: INFO/sysproc(582): Entered system_init() 07-13 19:52:45.206: INFO/sysproc(582): ServiceManager: 0x16c838 07-13 19:52:45.206: INFO/SurfaceFlinger(582): SurfaceFlinger is starting 07-13 19:52:45.218: INFO/SurfaceFlinger(582): SurfaceFlinger's main thread ready to run. Initializing graphics...

Preload is often paired with prelink.

4th Korea Android Seminar 33/5 3 Start-up Walkthrough

Zygote Public Class for Developers

http://developer.android.com/reference/dalvik/system/Zygote.html

4th Korea Android Seminar 34/53 Start-up Walkthrough

Init starts runtime process: 1. Initializes Service Manager – the context manager for Binder that handles service registration and lookup. 2. Registers Service Manager as default context manager for Binder services.

Service Manager usbd adbd debuggerd daemons runtime Zygote

Init

4th Korea Android Seminar 35/53 Start-up Walkthrough

Runtime process sends request for Zygote to start System Service.

Service Manager usbd adbd debuggerd daemons runtime Zygote

Init

4th Korea Android Seminar 36/53 Start-up Walkthrough

1. Runtime process sends request for Zygote to start System Server. Æ frameworks/base/services/java/com/android/server/SystemServer.java . runtime->callStatic("com/android/server/SystemServer", "init2"); 2. Zygote forks a new VM instance for the System Service process and starts the service. Æ Zygote::forkSystemServer (in device/dalvik/vm/InternalNative.c). Æ com.android.server.SystemServer(in device/java/services/com/android/server). Æ system_init ( in device/servers/system/library/system_init.cpp).

Service System Manager Server usbd adbd debuggerd runtime Zygote Dalvik VM daemons

Init

4th Korea Android Seminar 37/53 Start-up Walkthrough

Zygote for Custom Prelink in Android service servicemanager /system/bin/servicemanager user system critical onrestart restart zygote onrestart restart media service zygote /system/bin/app_process -Xzygote /system/bin -- zygote --start-system-server socket zygote stream 666 onrestart write /sys/android_power/request_state wake onrestart write /sys/power/state on

./frameworks/base/cmds/app_process/app_main.cpp

4th Korea Android Seminar 38/53 Start-up Walkthrough System Service starts the native system servers, including: 1. Surface Flinger. 2. Audio Flinger.

Audio Flinger

Surface Flinger

Service System Manager usbd Server adbd debuggerd runtime Zygote Dalvik VM daemons

Init

4th Korea Android Seminar Start-up Walkthrough

Native system servers register with Service Manager as IPC service targets: Å IPCThreadState::self()->joinThreadPool()

Audio Flinger

Surface Flinger

Service System usbd Manager Server adbd debuggerd runtime Zygote daemons Dalvik VM

Init

4th Korea Android Seminar 40/53 Start-up Walkthrough

System Service starts the Android managed services: Content Telephony Bluetooth Connectivity Location Manager Service Service Service Manager Window Activity Package Power Manager Manager Manager Manager …

Camera Service Surface Flinger

Service Manager System usbd Server adbd debuggerd runtime Zygote Dalvik VM daemons

Init

4th Korea Android Seminar 41/53 Start-up Walkthrough

Android managed Services register with Service Manager: Content Telephony Bluetooth Connectivity Location Manager Service Service Service Manager Window Activity Package Power Manager Manager Manager Manager …

Service Camera Manager Service Surface Flinger

Service Manager System usbd Server adbd debuggerd runtime Zygote Dalvik VM daemons

Init 4th Korea Android Seminar 42/53 Communications Between zygote and Java app

Zygote System Server (Core Engine) Runtime Android Application Application zygoteinit Application init RuntimeFork Fork Content Thread

Dalvik socket ActivityThread Instrumentation

Window Activity Package Manager Manager manager

Fork Binder IPC

Java Process (Core Services , e.g: android.process.acore) Application Application Application Content Thread ☞Other JAVA process is created from ActivityManagerService (run in system_server process) like this. ActivityThread Instrumentation int pid = Process.start("android.app.ActivityThread", mSimpleProcessManagement ? app.processName : null, uid, uid, gids, ((app.info.flags&ApplicationInfo.FLAG_DEBUGGABLE) != 0), Window Activity Package null); Manager Manager manager

4th Korea Android Seminar 43/53 Start-up Walkthrough

Power … Manager Activity Manager

Camera Service Surface Flinger

Service System Manager usbd Server adbd debuggerd runtime Zygote Dalvik VM daemons

Init

4th Korea Android Seminar Start-up Walkthrough

After system server loads all services, the system is ready…

Init System Daemon runtime Zygote Server Processes

Activity Manager Package Manager Window Manager …

Dalvik VM

usbd Surface adbd Flinger debuggerd Init runtime Zygote Audio daemons Flinger

4th Korea Android Seminar 45/53 Start-up Walkthrough

After system server loads all services, the system is ready…

Init Daemon System Home runtime Zygote Processes Server Home Activity Manager Dalvik VM Package Manager Window Manager …

Dalvik VM

usbd Surface debuggerd Flinger adbd Init runtime Zygote Audio daemons Flinger

4th Korea Android Seminar 46/53 Start-up Walkthrough

After system server loads all services, the system is ready… System Server Home Init Daemon runtime Zygote Processes Activity Home Manager Package Dalvik VM Manager Window Manager …

Dalvik VM usbd Surface adbd Flinger debuggerd Audio Init daemons runtime Zygote Flinger

libc libc libc libc libc libc

4th Korea Android Seminar 47/53 Start-up Walkthrough Each subsequent application is launched in it's own process

runtime Daemon Zygote System Home Contacts Processes Server Activity Home Contacts Manager Package Dalvik VM Manager Dalvik VM Window Manager …

Dalvik VM

usbd Surface Flinger adbd Audio debuggerd runtime Zygote daemons Flinger libc libc libc libc libc libc

4th Korea Android Seminar 48/53 Relations between PID and TID by zygote

USER PID PPID VSIZE RSS WCHAN PC NAME root 1 0 252 164 c0082240 0000ab0c S /init root 536 1 740 312 c0141bb0 afe0c1bc S /system/bin/sh system 537 1 808 264 c01654b4 afe0c45c S /system/bin/servicemanager root 539 1 668 264 c0192c20 afe0cdec S /system/bin/debuggerd radio 540 1 5392 684 ffffffff afe0cacc S /system/bin/rild root 541 1 72432 25176 c008e3f4 afe0c584 S zygote media 542 1 17720 3528 ffffffff afe0c45c S /system/bin/mediaserver root 543 Parent 1 800PID 324 c01f3b04 afe0c1bc S /system/bin/installd root 549 1 3332 152 ffffffff 0000e8c4 S /sbin/adbd system 572 541 181016 24620 ffffffff afe0c45c S system_server radio 657 541 105856 17724 ffffffff afe0d3e4 S com.android.phone app_2 673 541 115412 21328 ffffffff afe0d3e4 S android.process.acore app_15 687 541 94492 13364 ffffffff afe0d3e4 S com.android.mms (Forked Process) app_0 703 541 94296 12656 ffffffff afe0d3e4 S com.android.alarmclock app_3 709 541 98380 12968 ffffffff afe0d3e4 S com.android.inputmethod.latin app_4 721 541 95416 13620 ffffffff afe0d3e4 S android.process.media system 723 541 98332 12536 ffffffff afe0d3e4 S com.android.settings

4th Korea Android Seminar 49/53 Relations between PID and TID by zygote

/proc/1 572 system_server 651 WifiService init 573 HeapWorker 652 WIfiWatchdogThread 574 Signal Catcher 653 AudioService Dalvik System 575 JDWP 654 android:unnamed Exec /proc/531 (Native Start) 576 Binder Thread # 655 android:unnamed 577 Binder Thread # 656 er$SensorThread zygote 578 Binder Thread # 661 watchdog 579 SurfaceFlinger 671 app_process 587 DisplayEventThr 672 GPSEventThread Fork /proc/572 588 er.ServerThread 693 Binder Thread# System Server 590 ActivityManager 694 Binder Thread# 591 ProcessStats 711 r.MountListener 592 PackageManager 738 Binder Thread# 604 FileObserver 739 Binder Thread# Create threads 642 SyncHandlerThread 643 UEventObserver /proc/572/task/ 644 PowerManagerServer 37 threads 645 AlarmManager 646 WindowManager 647 InputDeviceRead 652 WindowManagerPo 649 InputDispatcher 650 ConnectivityThread

4th Korea Android Seminar 50/53 Relations between PID and TID by zygote

/proc/1 861 app_process (com.android.browser ) init 862 HeapWorker 863 Signal Catcher Exec /proc/531 Dalvik System 864 JDWP (Java Debug Wire Protocol) zygote (Native Start) 865 Binder Thread # 866 Binder Thread # Fork /proc/861 867 Binder Thread # app_process 870 CookieSyncManager 872 AsyncTask #1 (computation that runs on a background thread) 873 WebViewCoreThread Create threads 876 WebViewCoreThread 877 WebViewCoreThread /proc/861/task/ 879 http0 16 threads 880 http1 881 http2 882 http3

4th Korea Android Seminar 51/53 THANKS

4th Korea Android Seminar 52/5352/53 MEMO

Android Prelink? Android prelink means that remove the need for most of the symbol lookups.

Android Zygote? A preforked process that the system keeps around that makes new application startup faster.

53/53 4th Korea Android Seminar