Linux kernel overview-linux Kernel

Source: Internet
Author: User
Tags comparison table

Linux Kernel Learning notes collation.

Unix

Unix has a history of 40, but computer scientists still think it is the largest and best system in the existing operating system, it has become a legendary existence, the test of time is still a reputation.

In 1973, after the UNIX system was rewritten in C, a large number of Unix-derived versions began to emerge, and many companies migrated UNIX to new models, and developers continued to enhance the system's functionality in their own way. Unix systems are designed to be concise and provide source code at the time of release, so many organizations have developed them further. The University of California, Berkeley, is one of the most influential. On the BSD basis, many vendors have also launched their own UNIX, such as SunOS, HP-UX and so on. In 1991, Linus published its Unix on the Internet. Linux then set sail, Linux quickly attracted a lot of developers, hackers to modify and improve their code, because of its open source, Linux quickly become a multi-person cooperation open source projects.

operating system and kernel

The operating system includes the kernel, device drivers, boot loader, command line shell, basic system Tools, and so on. The kernel is the real core of the operating system, which is responsible for the tasks of hardware equipment management and allocating system resources. The kernel is generally system-state, has a protected memory space, and all permissions to access hardware devices, and this system state and the protected space are collectively referred to as kernel space. Applications can only see some of the system resources that are allowed to access them in user space, use only certain system features, have no direct access to the hardware, and cannot access the memory range that the kernel has allocated to others, and there are other limitations. The application communicates with the kernel through system calls , allowing the kernel to perform different tasks on its behalf.

The kernel is also responsible for managing the hardware devices of the system. When a hardware device wants to communicate with the system, it sends out an asynchronous interrupt signal to interrupt the processor execution, which in turn interrupts the kernel execution. Interrupts usually correspond to an interrupt number, and the kernel finds the appropriate interrupt service program with the interrupt number and calls the program to respond and handle interrupts. The interrupt service program runs in a context that is not related to all processes, specifically processing interrupts, to ensure that the interrupt service program responds to and processes the interrupt request and exits quickly at the first time.

single core and micro core

The kernel of the operating system can be divided into two main camps: Single core and micro core. The single core is the whole of it as a large process to achieve, but also run in a separate address space, characterized by high performance. The microkernel is not implemented as a separate large process, it is divided into several independent processes according to the function, which is characterized by the independent operation of each process , which avoids the problem of one module harmful another. Compared to the single-core design more than the communication mechanism between the modules, and the single core does not have these message delivery overhead. Therefore, most micro-kernel-based systems allow most or all of the functional processes to run in the kernel, so that functions can be called directly, eliminating frequent context switches. Windownt, Mach is a typical example of micro-core. Linux is a single kernel, but it absorbs the essence of the microkernel. Linux is modular, multi-threaded, and the kernel itself can be scheduled operating system.

Kernel version number

The major version number. The secondary version number. Revision number

The sub-version number reflects whether the kernel is a stable version or a developing version: If the number is even, then this version is stable, and if it is odd, then he is the development version.

Get Source code

Website address: www.kernel.org

Warehouse Address: git.kernel.org

Compiling the kernel

Since the kernel has never been configured, the kernel is compiled with the default configuration, which is said to be the default configuration of Linus.

$ Make

If you want to reduce the output information during compilation, you can use the following command

$ make >: /detritus

This way, if you want to view the compilation information, you can view the file. Of course you can also redirect useless information directly $make >/dev/null.

Installing the kernel
 make Modules_install

The above command installs all the compiled modules into the correct home directory. At compile time, a System.map file is generated at the root of the kernel code, which is a symbol comparison table.

Kernel development

The performance requirements for kernel development are very high. Kernel development cannot access the C library, nor can it access the standard C header files. Kernel development must use GNU C, which is too large and inefficient for the kernel to have a full C library (or even a subset). But most of the common C Library functions have been implemented in the kernel. The kernel of Linux is mixed with C language and assembly language, and it is generally used in assembly language where it is close to the ground level or is strictly required for execution time. GCC supports the use of ASM () directives to embed reporting code in C.

Conditional branching optimization

For conditional selection statements, conditional branching can be optimized according to the branch declaration statement before compilation, when frequent conditions often occur or rarely occur. Example:

/**/if  (unlikely (err)) {    ...}

It is important to ensure that the current conditions are set up in the vast majority, and if you judge correctly, the performance of the program will be improved, otherwise it will degrade performance.

No memory protection mechanism

If the user program attempts an illegal memory access, the kernel discovers the error and ends the process. However, if the kernel itself accesses the memory illegally, the consequences will be difficult to control because there is nothing else to monitor the kernel. Also, the memory in the kernel is not paged.

Extended

The kernel has the highest privileges for the entire system, and there are a number of special considerations for kernel development that can be learned in a more professional article.

Linux kernel overview-linux Kernel

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.