Handling Linux kernel state missing page exceptions using abnormal tables

Source: Internet
Author: User
Use an exception table to handle Linux kernel state page missing exceptions-general Linux technology-Linux programming and kernel information. For more information, see the following. Preface

In the process of program execution, the CPU cannot finally access the corresponding physical memory unit because of some obstacles, that is, the ing from virtual address to physical address cannot be completed, the CPU generates a page missing exception to handle the page missing exception. Based On the CPU, Linux uses the Demand Paging and Copy On Write technologies.

1. Request paging is a dynamic memory allocation technique that delays page box allocation until it can no longer be postponed. The motive of this technology is that the process does not access all the content in the address space when it starts to run. In fact, some addresses may never be used by the process. The local principle of the program also ensures that at each stage of the program execution, only a small part of the Process page is actually used. For pages temporarily unavailable, its page box can be used by other processes. Therefore, the request paging technology increases the average number of free page boxes in the system, making good use of the memory. From another perspective, without changing the memory size, the request paging can increase the system throughput. When the page to be accessed by a process is not in the memory, the required page is transferred to the memory through page missing exception handling.

2. during write replication, the system calls fork. The Parent and Child processes share the page box in read-only mode. When one of them wants to modify the page box, the kernel allocates a new page box through the page missing exception handler and marks the page box as writable. This processing method can greatly improve the system performance, which has a certain relationship with the operation process of the Linux creation process. Generally, after a child process is created, execve is immediately called by the system to load the image of an executable program into the memory. In this case, the page box of the child process will be reassigned. Therefore, it is obviously inappropriate to copy the page box when fork is used.

In the preceding two cases, a page-missing exception occurs, and the process runs in the user State. The exception handling program allows the process to resume execution from the abnormal command, so that the user does not feel the exception. Of course, exceptions cannot be recovered normally. At this time, the exception handling program will do some aftercare and end the process. That is to say, if a page error occurs in a user-mode process, the stability of the operating system core will not be affected. What should I do if a page exception that cannot be recovered occurs for a process running in the core State? Will the system crash? Whether or not the kernel state page exception can be solved will have a great impact on the stability of the operating system core. If a misoperation occurs, it will cause the system Oops, this is obviously intolerable for users. This article focuses on this problem and introduces a solution adopted in the Linux kernel.

Before readers continue reading, there is a need to explain first, the sample code selected in this article is taken from the Linux-2.4.0, the compiling environment is gcc-2.96, the version of objdump is 2.11.93.0.2, you can use the following command to query the specific version information:
CODE: $ gcc-v
Reading specs from/usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
Gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)
$ Objdump-v
GNU objdump 2.11.93.0.2 20020207
Copyright 2002 Free Software Foundation, Inc.
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.