The reason for using the system call and the difference between it and the library function (api)

Source: Internet
Author: User

Why do we need a system call? There are two main reasons.

(1) system calls provide a unified interface for user space to access hardware resources, so that applications do not have to pay attention to specific hardware access operations. For example, when reading and writing files, applications do not have to worry about the disk type, or even the file system.

(2) system calls can protect the system to ensure system stability and security. The existence of system calls specifies the specific way for a user process to enter the kernel. In other words, the path for the user to access the kernel is specified in advance and can only enter the kernel from the specified location, rather than jumping into the kernel. With this unified access path restriction, You can ensure kernel security.

(3) system calls have stronger functions.

Differences between system calls and library functions:

1. system calling is used to facilitate the application to use the interface of the operating system, and library functions are used to facilitate the compilation of applications. For example, you can compile a function by yourself, which can be called a library function.

2. system calls can be understood as the interface functions provided by the kernel to us in the user State. They can be considered as some kernel library functions.

3. the main function of the operating system API is to completely display the functions of the operating system and provide them to applications. Based on the operating system, ability to interoperate with files, memory, clock, network, graphics, and various peripherals. In addition, the operating system API usually provides many tool functions, such as manipulating strings, various data types, and time and date. There is a direct relationship between API functions and system calls. An API function can be called by one system or multiple systems, it can also be called without any system at all.

4. The system call efficiency is not necessarily higher than the database function.

Related Article

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.