These interfaces give applications controlled access to hardware, a mechanism with which to create new processes and communicate with existing ones, and the capability to request other operating system resources.
First, it provides an abstracted hardware interface for user- space.When reading or writing from a file, for example, applications are not concerned with the type of disk, media, or even the type of filesystem on which the file resides.
Sec- ond, system calls ensure system security and stability.With the kernel acting as a middle- man between system resources and user-space, the kernel can arbitrate access based on permissions, users, and other criteria.
Finally, a single common layer between user-space and the rest of the system allows for the virtualized system provided to processes
The mechanism to signal the kernel is a software interrupt: Incur an exception, and the system will switch to kernel mode and execute the exception handler.
The defined software interrupt on x86 is interrupt number 128, which is incurred via the int $0x80 instruction. It triggers a switch to kernel mode and the execution of exception vector 128, which is the system call handler.The system call handler is the aptly named function system_call().
On x86, the syscall number is fed to the kernel via the eax regis- ter.
The parameters are stored in registers. On x86-32, the registers ebx, ecx, edx, esi, and edi contain, in order, the first five arguments. In the unlikely case of six or more argu- ments, a single register is used to hold a pointer to user-space where all the parameters are stored.
The return value is sent to user-space also via register. On x86, it is written into the eax register.
普适性,不能轻易更改
需要验证参数的合法性和有效性 -- For example, file I/O syscalls must check whether the file descriptor is valid. Process- related functions must check whether the provided PID is valid. Every parameter must be checked to ensure it is not just valid and legal, but correct. Processes must not ask the ker- nel to access resources to which the process does not have access.
需要验证进程是否用户执行该系统函数的权限