Detailed Linux system call process __linux

Source: Internet
Author: User

The level of Linux system calls is as follows:

User Program-------->c library (API): INT 0x80------------>system_call------------> System Invoke Service routine---------> kernel program

The API is the C library provided by the system. System calls are implemented through a soft interrupt instruction int 0x80.

(1) INT 0x80: Encapsulated in the C library function, executing this instruction will allow the new system to jump to a preset kernel space address, which points to the system call handler, that is, the System_call function

(2) System_call: Go to execute specific system call service routines according to the specific system call number.

Procedure: To find the system call table sys_call_table through the system call number, the system call number is placed in the EAX register (because the system call service routine will only fetch parameters from the stack) when the soft interrupt instruction 0x80 executes system_ The call function can read the EAX register fetch (the System_call function executes when the registers are pressed into the stack), multiplies it by 4, generates an offset address, and then sys_call_table as the base address, plus the offset. You can get the address of the specific system call service routine, then you can get the system service routines (the kernel implementation function for a specific system call), which is a boot process that precedes the execution of the system call service routines and is directed to all system calls for int 0x80 this instruction.


The system call 0x80 into the kernel through a soft interrupt int, jumps to the system call handler System_call function, and then processes the corresponding service routines. However, because it represents a user process, the execution process does not belong to the interrupt context, but to the process context. Therefore, in the process of system call, you can access a lot of information about the user process, can be preempted by other processes, can hibernate.

When the system call is complete, the control is returned to the user process that initiated the call, and the kernel has a schedule. If a higher priority process is found or the time slice of the current process is exhausted, a higher priority process is selected or the process is selected for execution

Two. The meaning of system call

The system call adds a middle layer between the user space process and the hardware device, which functions:

1. Provides a unified hardware abstraction interface for user space.

2. Ensure the stability and security of the system (can avoid the application of improper use of hardware devices, steal other processes of resources)

3. If the application has access to hardware at will, and the kernel knows nothing about it, multitasking and virtual memory are virtually impossible to achieve and, of course, do not achieve good stability and security

In Linux, the only means by which user space accesses the kernel during system calls, except for exceptions and interrupts, are the only portals to access the kernel.






Reference Blog: http://blog.sina.com.cn/s/blog_9df3658301011b7f.html


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.