Reasons for using system calls and how they differ from library functions (APIs)

Source: Internet
Author: User

Why do I need a system call? There are two main reasons for this.

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

(2) system call can protect the system, ensure the stability and security of the system. The existence of a system call specifies how the user process enters the kernel, in other words, the path of the user's access to the kernel is predetermined and can only be entered into the kernel from the specified location, without allowing arbitrary jumping into the kernel. The security of the kernel can be ensured by having such a unified access path restriction into the kernel.

(3) The system call has a stronger function.

The difference between a system call and a library function:

1. The system is called to facilitate the application of the interface using the operating system, and the library function is to facilitate people to write applications, such as you write a function you can actually say is a library function.

2. The system call can be understood as the kernel provided to us in the User state interface function, can be considered to be some kind of kernel library function.

3. The main role of the operating system API is to fully display the functions of the operating system, to provide applications, based on the operating system, and file, memory, clock, network, graphics, various peripherals and other interoperability capabilities. In addition, operating system APIs often provide functionality for many tool classes, such as manipulating strings, various data types, time dates, and so on. There is a direct relationship between the API function and the system call, an API function can be implemented by a system call, can be implemented by invoking multiple system calls, and no system calls can be used at all.

4. System call efficiency is not necessarily higher than the library function

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.