Zhu Shushu Original works reproduced please specify the source "Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000
Typically, in the core of the OS, a set of subroutines (procedures) are set up to implement various system functions, and they are made available to the user to invoke the system procedure whenever the user needs to provide a service to the system. After invoking the system procedure, the program runs from the user state to the kernel state, the corresponding stack is also transferred from the user stack to the kernel stack, and the equivalent of the work of the protection site, the current state, stack top pointer, Cs:eip saved to the kernel stack. By breaking into the kernel state, the return time needs to be re-dispatched (so not necessarily directly back to the calling process), while recovering the scene through the iret operation.
The system call procedure is simple, it is entered by the 0x80 interrupt vector into the system call portal, which is implemented by using the system call table to save the address of the system service function. The specific process can be as follows:
0x80 Pass control to the core. A 0x80 is a vector address of a system call. This interrupt vector table is initialized at the start of the system, as well as some vector addresses, such as the system clock. When the user system is called, do the following:
Each system call is represented by the Lib library. Each system call in the Lib library is typically a macro syscallx (), and X is a numeric parameter for a specific invocation. Some system calls are more complex because they have variable
Parameter list, but they still use the same entry pointer. Each system call macro expands into a assembly segment that is used to establish the calling stack segment and then calls--entry (System_call) by calling break int $0x80.
System call Processing "Understanding: It is entered by the 0x80 interrupt vector into the system call portal, by using the system call table to save the address of the system service function in the form of implementation .
Process of system call System_call