Init Analysis for Android source code analysis

Source: Internet
Author: User

after initialization, uboot calls start_kernel to run Linux kernel.
just now, I simply looked at kernel 3.4. Now, the kernel runs init in the form of creating a kernel thread. For more information about Code , see init/main in Linux kernel code. c start_kernel-> rest_init: the kernel thread is created in rest_init. The Handler function of this thread is init_post, in init_post, the system calls
run_init_process ("/sbin/init");
run_init_process ("/etc/init ");
run_init_process ("/bin/init");
run_init_process ("/bin/sh");
earlier Linux kenel versions do not support kernel threads, it calls init directly in start_kernel.
the android init file is not complex in the system/CORE/SH/init. C code. A simple analysis is as follows:

1.ProgramFirst, determine whether it is run as ueventd. If so, run the ueventd logic.
2. Create the structure of the file system/dev,/proc,/sys, and mount tmpfs.
3. Create the/dev/. Booting file.
4. open_devnull_stdio: create a character device/dev/_ null _
5. Create a character device for klog using klog_init
6. Read the configuration file from init. C.
7. Read the configuration information focused on the local machine/init. machinename. RC
8 ...... read each configuration item and start execution.

The init. RC Script is a key aspect of the entire android system. All the keywords supported by init. Rc are included in core \ init \ keywords. h.
The numerous details in Android are classic. the RC parsing architecture can be reused in your own projects, simple parsing of configuration files, or a simple script engine.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.