Linux System Initialization Process __linux

Source: Internet
Author: User

Linux system startup, refers to the system from the power to the system console display "Login:" Login prompt to the operating stage, and the most closely related to this part of the code is: four assembler: Bootsect. S Setup. S head. S entry. S

MAIN.C files under the init directory

Primarily view the Start_kernel functions in INIT/MAIN.C:

In the system startup process, the main focus on several aspects: Interrupt system and scheduling system initialization of the file system of the equipment Management system initialization Network protocol initialization

Reset_init functions in INIT/MAIN.C:

In this function, there is the Kernel_thread function, which creates the kernel thread, and the prototype is as follows:

int kernel_thread (int (*FN), void *arg, unsigned long flags)

This function is defined in ARCH/XXX/KERNEL/PROCESS.C, which uses the Do_fork () function to create a new kernel-state thread, where Linux kernel threads are processes that do not have virtual storage space, run in the kernel, and use the physical address space directly.
The new kernel thread created by Kernel_thread is init, then returns, executes Unlock_kernel (corresponds to Lock_kernel in Start_kernel), and then executes Cpu_idle (), This is actually the end of the initialization of the main thread: it observes whether it is in tif_need_resched--in need_resched implementation, if not, let oneself sleep, no person completes schedule () function. TIF is the meaning of thread information flag.

Next move to the init function:

The init thread calls many functions, but the network-related sock_init () initialized in Do_basic_setup, and then continues to execute the Do_initcalls function, which is defined in the C file with two important variables __initcall_start and __initcall_end, they are defined as follows:

extern initcall_t __initcall_start, __initcall_end;
static void __init do_initcalls (void)
{
    initcall_t *call;
    int count = Preempt_count ();
    /* from start traversal to end*/for
    (call = &__initcall_start; Call < &__initcall_end; call++) {
        char *mesg;
        ......
        (*call) ();

        msg = NULL;
}

}

The initcall_t class and __initcall_start,__initcall_end are defined in init.h files in the Include/linux directory.

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.