The third week constructs a simple Linux system menuos

Source: Internet
Author: User

I. Introduction to Linux kernel source code

Stable version kernel: Linux-3.18.6

Directory structure of the Linux kernel source code:

Arch Catalog: In the Linux kernel source code occupies a large proportion, because the Linux kernel supports a lot of architectures, and the Arch directory is to support different CPU source code. arch/x86 directory is the key

Documentation Directory: Document Directory

FS Directory: File system

Init directory: Kernel boot-related code is basically in the Init directory, where the Start_kernel function in the main.c code is equivalent to the main function of the normal C program

IPC Directory: interprocess communication

Kernel Directory: Core code of the Linux kernel in the kernel directory

LIB directory: common library files

MM Directory: Memory-managed

Readme directory:

Two. Construct a simple Linux system

L Open the shell using the virtual machine of the lab building

Enter menu program after kernel boot, support three commands help, version and quit

L TRACE the kernel through GDB

L build menuos with your own Linux system environment

Init is the first user-state process

L reconfigure Linux to carry debug information

    1. On the basis of the original configuration, make Menuconfig Select the following option to reconfigure Linux to carry debug information
    2. Make recompile (longer)

L use GDB to track debug kernel

Freeze the-s:cpu before initializing it.

-S: A gdbserver is created on the port

Open another Shell window

Three. Track the boot process of debugging Linux kernel

The experiment is as follows:

Simple analysis of Start_kernel:

Init_task the pcb,0 process, which is created manually, is the final idle process

Regardless of which part of the analysis kernel will be involved in Start_kernel

Trap_init (): Initialization of some interrupts

Dispatched to the idle process when no process is required for the system to execute

Four. Summary

Init is the first to invoke a program compiled with the standard C library. Prior to this, no standard C application was implemented. On a desktop Linux system, the first program to start is usually/sbin/init, which has a process number of 1. The init process is the initiator and controller of all processes, and it has two functions:
(1) Play the role of ending the parent process: All orphan processes will be taken over by the INIT process.
(2) System initialization work: such as setting keyboard, font, loading module, setting up network, etc.

After the initialization of the system, the INIT process will run the Getty (Login program) on the console and the login interface we are familiar with appears.

The third week constructs a simple Linux system menuos

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.