In-depth understanding of system calls and library function calls!

Source: Internet
Author: User

Today, we have summarized system calls and library function calls! Write down your experiences here. If you have any mistakes, I hope you can point them out.

Let's assume that the UNIX system library functions are provided by the C compiler, And you can compile the C library functions in compilation!

First, you need to know the differences between system calls and database functions at a macro level: system calls are provided by the operating system.

The library function is provided by the compiler.

However, we know that system calls will fall into the kernel through a trap mechanism and execute corresponding processing programs.

Why should we fall into the kernel? Because the system is divided into kernel and user States. For example, we perform corresponding operations on an I/O, assuming that the assembly language is used, these access I/O commands can be used only in kernel mode.

In this way, we will know that when I/O access (control hardware, or access to kernel data, system status access, and process management) will all fall into the kernel, to use related commands

The library functions or API user programming interfaces that we call are not system calls. They call the corresponding functions only when the functions that need to be completed by the kernel are involved, for example, the printf () function calls weite () called by the system (). enter the kernel to complete the function.

Functions such as ABS () do not need to be written into the kernel, and system calls are not required in database functions. because they access user space data (Program body, data zone, and stack zone.

When you compile a library function using the Assembly, BIOS interruption is also required to implement some tasks completed by the kernel. the BIOS interruption is already in the kernel. if you directly access the I/O port address, such as writing a screen directly, you need to enable CPU interruption CLD/STD, which has already entered the kernel.

I would like to thank a friend for his help and hope you can tell me if you find any error. Thank you!

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.