Android: v2.3.41. init. after the Clinux kernel is started, init is the first Android user process system/CORE/init. CINT main (INT argc, char ** argv) {/******* create the linux root file system directory ************/mkdir ("/dev", 0755 ); mkdir ("/proc", 0755); mkdir ("/sys", 0755); mount ("tmpfs", "/dev", "tmpfs", 0, "mode = 0755"); mkdir ("/dev/PTS", 0755); mkdir ("/dev/socket", 0755); mount ("devpts ", "/dev/PTS", "devpts", 0, null); mount ("proc", "/proc", "proc", 0, null ); mount ("sysfs", "/sys", "sysfs", 0, null); // open the standard input, output, and error file descriptor open_devnull_stdio (); // read and parse init. RC init_parse_config_file ("/init. RC "); // run/proc/cmdline to obtain the startup command. // extract information kernel startup parameters from/proc/cmdline and save them to the global variable import_kernel_cmdline (0 ); // get the hardware name get_hardware_name (hardware, & revision) through/proc/cpuinfo; // read and parse the hardware-related init script file snprintf (TMP, sizeof (TMP ), "/init. % S. RC ", hardware); init_parse_config_file (TMP ); /***** trigger the action named early-init In the init script file and execute the ***/action_for_each_trigger ("early-init ", action_add_queue_tail); // initialize queue_builtin_action (lele_init_action, "console_init");} static int console_init_action (INT nargs, char ** ARGs) {/*** to check whether a console exists, if not, use the default *********/If (console [0]) {snprintf (TMP, sizeof (TMP ), "/dev/% s", console); console_name = strdup (TMP);}/***** open the console, if no console is specified in cmdline, open/dev/console FD = open (lele_name, o_rdwr);/***** # define init_image_file "/initlogo. rle "@ * read initlogo. rle. is a 565 RLE Compressed boot logo in the root file system @ * if it is enabled successfully, the logo is displayed in/dev/graphics/fb0. If it fails, enable/dev/tty0 to display @ * Android text */If (load_565rle_image (init_image_file) {FD = open ("/dev/tty0", o_wronly ); if (FD> = 0) {const char * MSG; MSG = "\ n" "\ n" \ n "// console is 40 Cols x 30 lines" \ n "" a n d r o I d "; write (FD, MSG, strlen (MSG); close (FD) ;}} 2. use the startup script init In the init script language android. RC, init STARTUP script path: System/coer/rootdir/init. rcinit. RC is installed in the root file system and parsed by the init executable program init. for the use of RC scripts, refer to system/CORE/init/readme.txt. All the characters are in the unit of action. Various symbols are separated by spaces. backslash numbers can be used to insert Space 1 between marks) action is actually a series of commands. Actions has a trigger to determine the action execution time actions take the form: on <trigger> <command> on early-init on FS on post-Fs on boot on property: Ro. secure = 0 on property: Ro. kernel. qemu = 1 on property: persist. service. ADB. enable = 1 these triggers are triggered by init. the handler ("early-init", action_add_queue_tail); handler ("init", action_add_queue_tail); action_for_each_trigger ("early-Fs", action_add_queue_tail ); round ("FS", action_add_queue_tail); Round ("post-Fs", action_add_queue_tail); Round ("early-Boot", action_add_queue_tail); Round ("Boot", action_add_queue_tail ); 2) services indicates that an executable program is started, the options option is the additional content of the service used together with the Service to use the service <Name> <pathname> [<argument>] * <option> name: Service name pathname: the program location corresponding to the current service options: options set for the current service 3) Options options are modifiers to services. they affect how and when initruns the service. critical: if the service exits more than four times in four minutes, the system will restart and enter the recovery mode service ueventd/sbin/ueventd criticaldisabled: the service will not start automatically under the same trigger as it, he must be explicitly named to start service adbd/sbin/adbd disabledsocket: Create socket service vold/system/bin/vold socket vold stream 0660 root Mount ioprio be 2 User: change the Service User Name Service Media/system/bin/mediaserver user mediagroup: Change the Service Group Name Service bootanim/system/bin/bootanimation user graphics group graphicsoneshot: when the service exits, do not restart service flash_recovery/system/etc/install-recovery.sh oneshotifup: Start Network Interface on boot IFUP lo IFUP usb0 hostname localhosthostname: Set host name insmod: Load module mount in path: mount the tmpfs/mnt/ASEC mode = 0755, gid = 1000 setprop: sets the system attribute init. important Service zygote/system/bin/app_process-xzygote/system/bin -- zygote -- start-system-server in RC creates the Dalvik Java Vm, and then starts systemserver, start all android services, and finally start the Android system service servicemanager/system/bin/servicemanager to open the binder driver. The binder is the underlying implementation of the android service communication mechanism, this service encapsulates the binder operation interface