The 4th week of Linux kernel analysis

Source: Internet
Author: User
Tags function definition

Wang Yi Original Works reproduced please specify the source "Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000

I. Status of the Linux system

Linux supports 0 kernel states and 3 user configurations under the x86 platform. In the kernel State 32-bit platform can access the space above 0x00000000, and the user state can only access the address space less than 0xc0000000

(The address space here is a logical address). The primary mode is interrupt when the user state switches to the kernel state.

1. When int128 is called, the system automatically cs:eip,ss:esp,eflags the two states (flag registers) to the stack. Loads the current interrupt's processing entry into the CS:EIP and loads the current stack segment into the SS:ESP.

2, after entering the interrupt, will save most of the value of the General register. (Save_all). Conversely, these registers (Restore_all) are pop when exiting.

Second, the system calls

1. The user-state process invokes a set of interfaces for the hardware device. Increase security and enhance portability.

System calls are a special way of breaking

The API is simply a function definition, whereas a system call is a soft interrupt to the kernel.

The system call corresponds to the encapsulation routine, which invokes the API functions in the LIBC library.

The return value of the encapsulation process depends on the system call. -1 indicates that the request cannot be fulfilled.

Three-layer call relationship:

System call , (API) xyz ()->int0x80 (EAX pass-through parameter-system call number)---------into the kernel state------>system_call () sys_xyz ()->system_call ()->iret

If more than one parameter is entered, it is saved to a different register (EBX,ECX,EDX.ESI,EDI,EBP up to 6), which holds the memory address of the data to be entered.

The experiment uses the MKDIR function to create a folder:

The 4th week of Linux kernel analysis

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.