Abnormal Exception Handling Methods in Linux

Source: Internet
Author: User
Abnormal Exception Handling Methods in Linux-general Linux technology-Linux programming and kernel information. For details, refer to the following section. If an exception occurs in linux, the chip will automatically generate an exception interrupt. In this exception interrupt handler, the system determines that the exception comes from the user program or kernel. If the exception occurs in the user program, an exception signal is generated, then, notify the user program of exceptions based on the callback function of the exception signal. If an exception occurs in the kernel, the system searches for the exception structure table of the kernel module, finds the corresponding address for processing the call, and modifies the return address of the exception interruption to the address for exception handling, when the return result is interrupted, the program jumps to the exception handler for processing and execution. However, the two methods are both very bad. Let's take a brief analysis.

In linux, the data structure of all processes is stored in the kernel, which increases unnecessary switching times. Linux can install the signal callback function through system calls. The callback function pointer is stored in the process data structure of the kernel. This is a good solution for windows. windows divides the process data structure into two parts. Some of the sensitive data is stored in the kernel's process data structure for protection, the other part of the non-sensitive data is stored in the user space. In this way, when accessing unprotected data, you do not need to switch to the kernel, saving time. For example, exception handling in windows is also a callback function. However, because the structure is stored in the user space, it is easy to install and saves switching time.

The above is only a matter of efficiency, but the Linux kernel exception handling is terrible. First, let's introduce the exception handling structure of the Linux kernel. Once you understand it, you will naturally know how bad it is. To understand this, it is obvious that we should start with an exception interrupt. The following mainly deals with x86 chips, but other chips should be similar.
QUOTE:
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.