Linux kernel design and implementation of a book reading the 12th chapter integration

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

Chapter One: Introduction to the Linux kernel

I. Unix and Linux

UNIX is a powerful, robust, and stable operating system.

1.UnixKernel features
    1. Very concise: Provide only hundreds of system calls and have a clear purpose;
    2. In Unix , most things are treated as files (or are committed);
    3. Unix kernel is the related system tool software is written in C language, which makes the system has a strong portability;
    4. Unix processes are created very quickly, with the goal of performing a task at once with quality and quantity
2.Linuxwith theUnixsimilarities
  • Linux is a Unix -based class system, such as it also implements the Unix API;
  • But it differs from Unix, and does not utilize UNIX kernel source code;
  • Linux is a non-commercial product and anyone can participate in its development
  • Unix kernel vs . Linux kernel
  • The Unix kernel is an inseparable static executable library that typically requires a hardware system to provide a page mechanism (MMU) to manage memory;
  • Linux supports dynamic loading of kernel modules and is preemptive.

. Linuxthe system is based on the kernel,Clibraries, and basic tools for toolsets and systems.

Ii. Introduction to operating system and kernel

Operating systems are those parts of the entire system that are responsible for the most basic functions and systems management.

    • Kernel
    • Device drivers
    • To start the boot program
    • Command line Shell or other kind of user interface
    • Basic file management tools and System Tools

The kernel is isolated from normal applications, is generally system-state, has a protected memory space, and has all the permissions to access hardware devices.
This system state and the protected memory space, collectively known as the kernel space.
Applications running in the system communicate with the kernel through system calls.

Kernel classification
    1. Single core (e.g. most Unix and Linux)
    2. The kernel is implemented as a large, separate process and runs on a separate address space
    3. Simple, high performance
    4. Microkernel (e.g. Windows NT)
    5. The functionality of the microkernel is divided into separate functions, each of which is called a server, facilitates the processing of inter-core communication, and uses the IPC mechanism;

The basic behavior of the application to complete its work is:

The application is trapped in the kernel through the system call interface.

The activity of the processor must be one of the following three:
    • Run in user space, execute user process
    • Runs in kernel space, is in the process context, executes on behalf of a particular process
    • Runs in kernel space, is in the interrupt context, is independent of any process, and handles a specific interrupt
Chapter two departs from the kernel 1.Source Code Control
    1. Using Git
    2. Git as a version control system to manage the Linux kernel source code;
    3. Download and update the latest version:
    4. git clone git://[ URL ]
    5. Kernel source code is generally installed in the /usr/src/linux directory, this source tree is not used for development
    6. Source Code Tree
    7. There are many directories worth noticing:
    8. Arch: Source code for a particular architecture;
    9. Include: kernel header file;
    10. Kernel: A core subsystem such as a scheduler.
2. Kernel source tree

3. Compiling the kernel
  1. Purpose: Compile the functions you need into the kernel
  2. Steps:
  3. Configuring the Kernel
  4. Premise: The various variables that can be configured are represented by the config_ prefix. There are two options (yes or no) and three select one (there is also a module, that is , The configuration item is selected but compiled in the form of modules); "My personal understanding is that This option is required for program code that is similar to a driver that requires modularity, which is more independent of the functionality but not necessarily open at all times.
  5. Way:
  6. Make config"This has been done in the experiment, it should belong to the kind of fool-by-one traversal (for the system is relatively simple case)"
  7. Make Menuconfig
  8. Make Gconfig
  9. Subsequent:
  10. Configuration options ConfigIkconfigproc put the full compressed configuration file under /proc/config.gz , so that when compiling the new kernel, you can copy it directly.
  11. Deriving multiple compilation jobs
  12. In general, each processor will derive 1--2 jobs to improve processor utilization
  13. Make-j32 >/dev/null"with a core processor as an example"
  14. Install the new kernel
  15. run make modules_install as root
  16. All compiled modules will be installed under lib/modules
  17. Kernel development can neither access C Library nor access standard C header files
    Response: Theinclude/linux folder contains the required kernel header files.
  18. The kernel programming must use the GNU C
4. Features of kernel development

Inline functions:
The function expands at the point where it is called.
When defining, you need to use static as a keyword to qualify it with inline.
Inline functions must be defined before they are used, and are generally defined in the header file.
The kernel takes precedence over the use of inline functions instead of macros.

Inline assembly:
Assembly code is typically embedded using asm () directives, which are not optimized with volatile representations

    1. Branch declaration:
      Unlikely (x)-X rarely appears, seldom occurs, usually false
      Likely (y)-y often appears, usually true
    2. Kernel programming lacks a memory protection mechanism like user space
      The memory in the kernel is not paged.
    3. Difficult to perform floating-point arithmetic during kernel programming
    4. The kernel gives each process only a small fixed-length stack
    5. Because the kernel supports asynchronous interrupts, preemption, and SMP, you must always be aware of synchronization and concurrency
      SMP: Symmetric multi-processing system.
      Common ways to solve competition: spin locks and semaphores.
    6. To consider the importance of portability
      such as keeping the byte order, the four bits on it, does not assume the word length and page lengths .

Summary: The content of these two chapters is relatively small, or easy to understand, because there are Lou teachers of the school-time professors, all aspects of the same as in the review of the knowledge of learning. The author also wrote very interesting, a kind of more approachable feeling.

Linux kernel design and implementation of a book reading the 12th chapter integration

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.