On Dec 2, 4:06 am, bacchus <[email protected]> wrote:
> By startup, I mean to understand how the Android Runtime is setup and
> Dalvik is started.
>
> Throughout the code reading process I've found VMRuntime.

VMRuntime doesn't have a whole lot to do with that.  It just has some
utility functions.  The class is defined here:

  dalvik/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java

The native methods it refers to are defined here:

  dalvik/vm/native/dalvik_system_VMRuntime.c


The VM is created by frameworks/base/core/jni/AndroidRuntime.cpp:

    if (JNI_CreateJavaVM(pJavaVM, pEnv, &initArgs) < 0) {

The runtime initialization does a bunch of jumping around, some of
which is cruft from the days before the "zygote" stuff existed.
Here's a part of an explanation I wrote about a week ago when
discussing something related:

-----
AndroidRuntime.cpp starts the VM, calls into RuntimeInit.main().
Crazy things happen.  We end up in ZygoteInit.main(), which has been
requested to call Zygote.forkSystemServer() to create system_server.
The zygote goes to sleep on a socket.

(All of the magic forking and such happens in dalvik/vm/native/
dalvik_system_Zygote.c .)

At this point we have two processes: zygote (a VM with a single thread
that is listening on a socket) and system_server (which was forked
from zygote and is now busily doing stuff).  When system_server
decides it wants to create a new app process, it sends an IPC to the
zygote process, which calls Zygote.forkAndSpecialize().

The forkAndSpecialize call takes a bunch of arguments, mostly having
to do with what uid and capabilities the new process should have.
(zygote runs as root.)  When the child process returns to Java-land,
it reads some more stuff from the command socket, then closes it.
-----

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to