Week4_linux Book 122 Chapters

Source: Internet
Author: User
Tags version control system git clone

the first chapter of the study is to have a basic understanding of the Linux kernel, but also know some knowledge about Linux.

Learn Linux, you can have a machine with Linux operating system, the role of the source code is irreplaceable; Linux Development Brief introduction: Linux is an important member of the Unix family, a college student Linus, His modifications to the UNIX source code have built the prototype of the Linux system, and the Unix family has adopted an open-source principle.

Linux operating system and other operating system differences: first introduce the single core and micro-core: Single core: The single core is to take it as a whole as a single large process to achieve, but also run in a separate address space, the kernel can directly invoke functions, this mode has a simple and high performance characteristics. Microkernel: The microkernel is not implemented as a single large process, and the functionality of the microkernel is divided into separate processes, each of which is called a server, and all servers remain independent in their respective address spaces. This does not directly invoke the function as a single-module kernel, but is implemented through message passing.

The Linux system is a single core, running on a separate kernel address space, modular design, preemptive kernel, kernel threading support, and the ability to dynamically mount kernel modules

the second chapter of the learning content is from the kernel to understand some of the basic knowledge of Linux kernel code, in favor of the subsequent learning of Linux kernel code
using a new version control system to manage the Linux kernel source code: Git
use the Git version to get the latest version of Linux code as shown in:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Once the code has been downloaded, you can update the branch to the newest branch of Linux:
$git Pull
the source code for the kernel may be compressed in two forms: Zip and bzip2if the form of compression is bzip2, extract the code: $ tar xvjf linux-x.y.z.tar.bz2if the form of compression is GNU zip, unzip the code: $ tar xvzf linux-x.y.z.tar.gzNote: Using the above methods, the kernel source code is generally installed in the/usr/src/linux directory, but this source is best not to be used for development, and do not change the kernel as root. The kernel source tree looks like this: to compile some content of the kernel:1. Configure the kernel: There are three optional options for configuring the kernel: Yes, no or moduleWhere yes means that the code is compiled into the main kernel image, not as a module, no is not compiled, the module indicates that the configuration item is selected, but the implementation of this part of the compilation is a module (a dynamic installation of independent code snippets) the kernel uses different tools to simplify the kernel configuration, Here are some common passwords:
$make config #这是字符界面的, used to traverse through all configuration options, requiring the user to select Yes, no or the module option $make menuconfig #用于gtk+ graphical interface tool to select directly, All configuration options will be categorized into $make gconfig #也是按照图形界面将配置选型分门别类的放置供用户选择. $make deconfig #基于默认的配置为你的体系创建一个配置. 

2.1 These configuration items are placed in the. config file in the root directory of the kernel code, you can modify it directly, after you have modified the configuration file, or configure the new code with the existing configuration file, you should verify and update the configuration, the command is:

$make Oldconfig
Configuration options Config_ikconfig_proc put the complete compressed kernel configuration file under/proc/config.gz, when the new kernel is compiled to easily clone the current configuration, if our current kernel has enabled this option, it can be very convenient from/ Proc Copy the configuration file below and use it to compile a new kernel, command:
$zcat/proc/config.gz >config$make oldconfig
After the kernel is configured, we can compile it with simple commands: $make 2.2 In order to reduce the compiled spam, you can redirect to a black hole/del/null with no return value by command.
At this point, enter the following command: $ make >/dev/null
2.3 In order to speed up the compilation process on the processor system and complete the compilation of the kernel in multiple jobs, the following command can be used:
$make-jn #其中n是要衍生出的作业数
For example, if on a 16-core processor, each processor derives one or two jobs, you can enter the following command:
$make-j32 >/dev/null
The 2.4 module is automatic and independent of the architecture, as root, as long as it runs:% make Module_install 3. Key features and considerations for kernel development kernel programming can neither access C libraries nor access standard C header files Kernel programming must use the gun C: inline function, when you define an inline function, you need to use static as the keyword, and inline to limit it, inline assembly, the format is as follows;
_asm_ (        Assembly statement module:        output part: Parameter input part of function call       : parameter       break description part when function call): The       format is ASM ("  Statements": Output_regs:input_regs:clobbered_regs);
kernel programming lacks a memory protection mechanism like user space difficult to perform floating-point arithmetic during kernel programming the kernel gives each process only a small fixed-length stack because the kernel supports asynchronous interrupts, preemption, and SMP, you must always be aware of synchronization and concurrency consider the importance of portability

Week4_linux Book 122 Chapters

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.