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!