1. Exception Handling
Linux uses exceptions to achieve two distinct purposes:
· Send a signal to the process to notify an anomalous situation
· Manage Hardware Resources < Br>
For the first case, for example, if the process performs a divide by 0 operation, the CPU will generate a <; division error & rdquo; exception, and the corresponding exception handler sends a SIGFPE to the current process signal. After the current process receives this signal, it takes a number of necessary steps to either recover from the error or terminate the execution (if there is no corresponding signal handler for this signal).
For the second case, the kernel uses two exceptions to efficiently manage hardware resources, and the corresponding handlers are more complicated. In this case, the exception does not indicate an error condition:
· Use the "Device Unavailable" exception to defer loading the floating point registers.
· Use “About page'; exception to postpone the new page frame to the process.
The kernel has a standard structure for the exception handler call, which consists of the following three parts:
· Saves the contents of most registers in the kernel stack (implemented in assembly language)
· Calling the exception handler written by C
· exits from the exception via the ret_from_exception() function.
The specific handling of exceptions in the kernel is not described in detail here. In Chapter 6, Memory Management, we will refer to the "pageout" exception handler. The focus of this section is on interrupt handling.
2. Interrupt Handling
When an interrupt occurs, not all operations have the same urgency. In fact, it is not appropriate to put all the operations into the interrupt handler itself. Long, non-critical operations that require a long time should be pushed back, because when an interrupt handler is running, the signal that is re-issued on the corresponding IRQ interrupt line is ignored. More importantly, the interrupt handler is executed on behalf of the process, and the process it represents must always be in the TASK_RUNNING state. Otherwise, system zombie may occur. Therefore, the interrupt handler cannot perform any blocking processes, such as I/O device operations. Therefore, Linux divides the operations to be performed by an interrupt into the following three categories:
(1) Critical (
such operations as interrupt controllers when an interrupt arrives Acknowledge, reprogram the interrupt controller or device controller, or modify the data structure accessed by both the device and the processor. These operations are urgent and should be performed very quickly, that is, emergency operations should be performed immediately within an interrupt handler, and the interrupt is disabled.
(2) Non-critical (Noncritical)
Such operations as modifying data structures that only the processor can access (for example, after scanning a key, read the scan code). These operations are also done very quickly, so they are executed immediately by the interrupt handler, but with interrupt enabled.
(3) Noncritical deferrable
This operation, for example, copies the contents of a buffer to the address space of some processes (for example, the keyboard line buffer) The content is sent to the process of the terminal handler). These operations may be delayed for longer intervals without affecting kernel operations: interested processes will wait for the required data. Non-emergency delayable operations are performed by a number of functions called "lower half" (bottom halves). We will discuss "lower part" in the following section.
All interrupt handlers perform four basic operations:
· Save the IRQ value and the contents of the register in the kernel stack.
· Sends an acknowledgment to the interrupt controller connected to the IRQ interrupt line, which will allow further interrupt requests to be issued on this interrupt line.
· Execute the Interrupt Service Routine (ISR) for all devices sharing this IRQ.
· Jumps to the address of ret_from_intr( ) and terminates.
Under Linux, the IDE device is named after hd. Generally, there are two IDE interf
First look at the TCP server side of the program: #include <stdlib.h> #include <stdio.h>
Today I made a simple ftp server for the company, and it was the first time I actually did the serv
Too many open files Errors are common faults in Linux systems. Solutions can be easily found on the
Configure dual NIC routing table
How to access Windows partitions under Linux
Precise timing and hibernation under Linux
Linux kernel source code structure overview
Memcache installation under Linux (with libevent installation) Tutorial
Wrong way to modify linux system file permissions
Play Samba server Samba to build a whole process
Linux NFS slow startup problem Boot acceleration Redhat change computer name Embedded linu
View the kernel version using the command line under Linux
Using ntop to efficiently troubleshoot Linux network problems
Win7 system installed network card driver computer no sound solution
Microsoft Win8 development process Accelerate Windows boot
Solving the problem that Vista can't use input method normally
Win10 mobile phone preview version 10136 one-hand mode to get started experience video
What are the shortcut keys for Windows 7 Ultimate system shutdown and restart
How to turn off the WIN7 interactive service detection prompt
Suggestions for backing up WinXP with GHOST
Win8 changed the library of the taskbar to the operation method of the computer