2.16.5. Kernel-initiated C-language Phase 2

Source: Internet
Author: User

This section begins by parsing the kernel's C phase according to the Code execution path. This lesson focuses on how the PRINTK function works and the kernel initializes the part of the banner information that is printed.
Reference: http://blog.chinaunix.net/uid-20543672-id-3157283.html

2.16.5.1, offal

(1) SMP. SMP is the Chenduo processor (which is what we call a multi-core CPU)
(2) Lockdep. Lock dependency is a kernel debug module that deals with kernel spin lock issues related to the deadlock problem.
(3) Cgroup. Control group, a technique provided by the kernel to process groups of processes.

2.16.5.2, print kernel version information

(1) Code in: 572 lines in KERNEL/INIT/MAIN.C

(2) The PRINTK function is used in the kernel to print information from the console, similar to printf in application-layer programming. Kernel programming cannot use standard library functions, so you cannot use printf, in fact PRINTK is the kernel's own implementation of a printf.
(3) The use of the PRINTK function is almost identical to printf, except that a macro can be used to define the level of the message output at the front of the parameter. Why do you have this level? The main reason is that the Linux kernel is too large, the code is too much, the PRINTK print too much information. If all the PRINTK can be printed without any restrictions, the final kernel will get a huge amount of output after it is booted.
(4) In order to solve the problem of excessive printing information and invalid information, the Linux kernel solution is to add a print level to each PRINTK. Level definition 0-7 (note that when programming with the corresponding macro definition, do not directly use numbers) represent the importance level of 8 output, 0 is the most important, 7 means the least important. We set the print level at the time of PRINTK, based on the importance of our own message.
(5) Linux console monitoring messages where there is also a message filtering display mechanism, the console will actually display only the level of messages that are higher than the level defined by my console. For example, if the console's message display level is set to 4, only the message level in PRINTK is 0-3 (or 0-4), and the rest is filtered out.
(6) Content analysis of Linux_banner.

Search in the compiled kernel: "grep" uts_release "*-NR
Linux_compile_by, Linux_compile_host, Linux_compiler, uts_version are also stretched out when compiling LINUX kernel, and can also be searched with grep xxx-nr commands. Its file is: Include/linux/compile.h.

2.16.5. Kernel-initiated C-language Phase 2

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.