Linux Kernel Concepts

Source: Internet
Author: User

Kernel kernel is only part of the operating system, and the operating system itself contains command-line shells and other kinds of user interfaces on top of the kernel.

Typically the kernel contains:

    • Interrupt Service Program
    • Process Management and Scheduler
    • Memory Management Program
    • Process synchronization Methods
    • IO and devices, etc.

In my development work, the emphasis is on the highlight of the three.

The application system communicates with the kernel through system calls:

For a description of the system call and Shell and library functions, excerpt from the online paragraph, as follows:

    • System call: For our convenience of invoking the kernel, we summarize the functionality of the kernel as a system call. The system call looks like a C-language function, and you can call it directly in the program as well. The Linux system has more than 200 such system calls. The system call gives the upper program a clear interface that hides the complex structure of the kernel. Enter $man 2 syscalls on the command line to see all system calls. You can also view the description of the system call read () by $man 2 read.
    • Library functions: Because system calls are very basic, it is sometimes cumbersome to use them. For example, a simple operation that allocates memory space to a variable requires multiple system calls. Linux defines some library functions (libraries routine) to combine system calls into some common functions to facilitate our programming. For example, above the allocation of memory operations, see as defined as a library function (like malloc () function).
    • Shell: As for the shell, it can be seen as a special application. In fact, the command line we talked about earlier is the shell. The shell is a command interpreter (interpreter) that, when we enter "Ls-l", interprets this string as 1), finds the file in the default path (/BIN/LS), 2) executes the file, and comes with the parameter "-L". We previously used the > to redirect, to express the pipeline, also through the shell to understand the meaning of & or |, and then through the system call command kernel to establish a specific redirection or pipeline mechanism.

About the user state and kernel state:

When a task (process) executes a system call and is executed in the kernel code, we say that the process is in the kernel run state (or simply the kernel state). At this point the processor is executed in the highest privileged (level 0) kernel code. When the process is in the kernel state, the kernel code that executes will use the kernel stack of the current process. Each process has its own kernel stack.

Kernel space and user space:

Kernel space is the kernel code and data, while the process of user space is stored in the user program code and data. Both the kernel space and the user space are in virtual space. internal and spatial and user space are isolated and in security considerations.

User stacks and Kernel stacks:

When the kernel creates a process, the colleague who creates the task_struct creates the appropriate stack for the process. Each process will have two stacks, a user stack, exist in the user space, a kernel stack, exist in the kernel space. When the process runs in user space, the contents of the CPU stack pointer register are the user stack address, the user stack is used, and when the process is in kernel space, the contents of the CPU stack pointer register are the kernel stack space address, using the kernel stack. When a process falls into a kernel state because of an outage or a system call, the stack used by the process goes from the user stack to the kernel stack.

Single Core and micro core

The operating system kernel may be a microkernel or a single kernel (the latter is sometimes referred to as the macro kernel Macrokernel). In the form of a similar package, these terms are defined as follows:

Microkernel (Microkernelkernel)-In a microkernel, the kernel is broken down into separate processes according to the function module, and they communicate through message delivery .

Single core (Monolithic kernel)-Single core is a big process. Its internals are also divided into modules, but these modules are all in one process.

Supporters of the single kernel claim that the message-passing overhead of the microkernel has caused a loss of efficiency. Proponents of the microkernel argue that the increased flexibility and maintainability of the kernel design can compensate for any loss.

Linux is a single core.

Linux Kernel Concepts

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.