Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Init of Android      2010.12.10Tetsuyuki Kobayashi                      1
Who am I?   20+ years involved in embedded systems       10 years in real time OS, such as iTRON       10 years in embe...
Todays topic   /init   Boot part of init   Daemon part of init   Check it out using debugger                          ...
/init   Quite different from usual Linux    system   Add ”init=/init” in kernel boot    parameter. Kernel searches only ...
/init   Android init is static linked. So it can    run standalone      (Linux /sbin/init is dynamically       linked. I...
Component of init   See the source code of init      system/core/init   Init is made of 2 parts: boot part    and daemo...
int main(int argc, char **argv){    /* Boot part   */     for (;;) {        /* Daemon part */    }}
Boot part   Setup the directories       /dev       /proc       /sys   Parse /init.rc and execute it   Yokohama Andro...
Daemon part   Waiting for 4 fds by poll system    call and handle these in forever    loop      device_fd      property...
device_fd   Receiving the device status    notification from kernel and create    or remove device files under /dev   In...
property_set_fd   Waiting for write request for    system property   Init process maintains master data    of system pro...
signal_recv_fd   Waiting for exiting child process    and finish them by waitpid system    call   If the child process i...
keychord_fd   Monitoring special key comination    and start the associated service   Effective only if system property ...
See also   KMC blog ”init of Android”       http://blog.kmckk.com/archives/3137191.html       This page have links of Y...
Q&AThank you for listening!Any comments to blogs are welcome.                                     15
Upcoming SlideShare
Loading in …5
×

Init of Android

6,432 views

Published on

  • Be the first to comment

Init of Android

  1. 1. Init of Android 2010.12.10Tetsuyuki Kobayashi 1
  2. 2. Who am I? 20+ years involved in embedded systems  10 years in real time OS, such as iTRON  10 years in embedded Java Virtual Machine  Now GCC, Linux, QEMU, Android, … Blogs  http://d.hatena.ne.jp/embedded/ (Personal)  http://blog.kmckk.com/ (Corporate) Twitter  @tetsu_koba 2
  3. 3. Todays topic /init Boot part of init Daemon part of init Check it out using debugger 3
  4. 4. /init Quite different from usual Linux system Add ”init=/init” in kernel boot parameter. Kernel searches only the following init  /sbin/init  /etc/init  /bin/init  /bin/sh
  5. 5. /init Android init is static linked. So it can run standalone  (Linux /sbin/init is dynamically linked. If some trouble in dynamic link system, the whole system wont work)
  6. 6. Component of init See the source code of init  system/core/init Init is made of 2 parts: boot part and daemon part  At first, boot part is executed once  After that daemon part executed repeatedly
  7. 7. int main(int argc, char **argv){ /* Boot part   */  for (;;) { /* Daemon part */ }}
  8. 8. Boot part Setup the directories  /dev  /proc  /sys Parse /init.rc and execute it Yokohama Android Platform club has a lot of information for this topic (written in Japanese)
  9. 9. Daemon part Waiting for 4 fds by poll system call and handle these in forever loop  device_fd  property_set_fd  signal_recv_fd  keychord_fd
  10. 10. device_fd Receiving the device status notification from kernel and create or remove device files under /dev In usual Linux system, udevd do this.
  11. 11. property_set_fd Waiting for write request for system property Init process maintains master data of system property. The other processes share it in read only mode by android ashmem mechanism. (Lets talk this in other session)
  12. 12. signal_recv_fd Waiting for exiting child process and finish them by waitpid system call If the child process is registered as service, restart it as registered info.
  13. 13. keychord_fd Monitoring special key comination and start the associated service Effective only if system property ”ro.debuggable” == ”1” || “init.svc.adbd” == “running” No services use this in default init.rc
  14. 14. See also KMC blog ”init of Android”  http://blog.kmckk.com/archives/3137191.html  This page have links of Yokohama Android Platform club, too.  Written in Japanese
  15. 15. Q&AThank you for listening!Any comments to blogs are welcome. 15

×