Communication between Liunx users and kernel space
Source: Internet
Author: User
Implementation of communication between Liunx users and kernel space-Linux general technology-Linux programming and kernel information. The following is a detailed description.
System Call
Communication between user space and kernel space
● Data structures and functions related to system calls
The name of the system call function starts with "sys _" and is followed by the name of the system call. As a result, 221 function names that are similar to sys_name () are formed. Include/asm-i386/unistd. h specifies a unique number for each system call. If the name is used to represent the name of the system call, the relationship between the system call number and the system call response function is: using the system call number _ NR_name as the subscript, you can find the content of the corresponding table item in the system call table sys_call_table, which is the entry address of the System Call response function sys_name.
● Specific execution process of system calls
When a system call is executed, the processor jumps to the address 0xc00.
Reference code:
Arch/ppc/kernel/head. S
/* System call */
. = 0xc00
SystemCall:
Prediction_prolog
/* Prediction_prolog is a macro responsible for switching from the user space to the kernel space, and needs to save the register status of the user process */
Stw r3, orig_upl3 (r21)
Li r20, MSR_KERNEL
Rlwimi r20, r23, 0, 16, 16/* copy EE bit from saved MSR */
Bl transfer_to_handler
. Long DoSyscall
. Long ret_from_except
For DoSyscall, it is defined in the file arch/ppc/kernel/entry. S. This function uses the system call number to load the address and index of the system call table. The operating system uses the system call table to translate the system call number into a specific system call.
The name of the system call table is sys_call_table, which is defined in arch/ppc/kernel/misc. S. The system call table package contains the address of the function for each system call.
_ GLOBAL (sys_call_table)
. Long sys_ni_syscall/* 0 old "setup ()" system call */
Long sys_getegid/* 50 */
. Long sys_acct
. Long sys_umount/* recycled never used phys ()*/
. Long sys_ni_syscall/* old lock syscall holder */
. Long sys_ioctl/* 54 */
. Long sys_fcntl/* 55 */
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