System call: The user state process to the kernel, to implement the user-state process calls the hardware Device function or interrupt;
Advantages: Making programming easier, freeing users from learning the low-level programming features of hardware devices, improving system-to-security, and enabling the kernel to check for correctness before satisfying requests; improve portability;
The difference between a system call and an API call:
1. The API call is a function definition; the system call is an explicit request to the kernel via a soft interrupt
2. The kernel can not access library functions
Kernel, the return value is positive or 0 indicates a successful end of the system call, otherwise indicates an error condition
Two ways to enter the kernel state: 1, execute int $0x80 instruction, 2, execute sysenter instruction
The kernel launches the system call way: 1, executes iret instruction, 2, uses sysexit instruction
System call Pass Parameters:
1, it saves the parameter in the CPU register, then reads by the kernel, cannot directly say the parameter from the user state stack passes to the kernel state stack, because this is more complex
2, the limit of the register, the number of parameters can not exceed 6; More than 6 May pass the address of a parameter collection
3, the length of the parameter is limited by the register, not more than 32bit, also can be addressed by the address.
Parameter check:
1.
Deep understanding of the Linux kernel-system calls