System calls and function calls

Source: Internet
Author: User
Function call

Look at this piece of code:

int main () {printf ("hello,world!"); return 0;}

The printf function is used, and the function is called from the standard C library and is actually going into the kernel state calling the write () function.

System calls

The application enters the kernel through the system call interface, first through the interrupt vector table to the system call table, each system call has the corresponding number, according to the number to implement the corresponding operation and return.

The difference between a system call and a function call

System invoke: Instruction int and iret stack switch (kernel and user state use different stacks), privilege level conversion

Function calls: Call and RET regular calls do not have a stack switch

System calls are more expensive because there is a user-to-kernel switchover, specifically:

Toggle boot (Hardware complete)

Kernel stack creation

Validation of validity of parameters

Kernel-state mapping to user-state address space

System calls and function calls

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.