So far, we've presented a variety of functions that your program can invoke to perform system-related functions, such as parsing command-line options, manipulating processes, and mapping memory. If you look under the hood, you'll find that these functions fall into two categories, based on how they are implemented.
libc. For example,
mkstempare functions provided in the C library.
A call to a library function is just like any other function call. The arguments are placed in processor registers or onto the stack, and execution is transferred to the start of the function's code, which typically resides in a loaded shared library.
The set of Linux system calls forms the most basic interface between programs and the Linux kernel. Each call presents a basic operation or capability.
Some system calls are very powerful and can exert great influence on the system. For instance, some system calls enable you to shut down the Linux system or to allocate system resources and prevent other users from accessing them. These calls have the restriction that only processes running with superuser privilege (programs run by the root account) can invoke them. These calls fail if invoked by a nonsuperuser process.
Note that a library function may invoke one or more other library functions or system calls as part of its implementation.
Linux currently provides about 200 different system calls. A listing of system calls for your version of the Linux kernel is in
/usr/include/asm/unistd.h. Some of these are for internal use by the system, and others are used only in implementing specialized library functions. In this chapter, we'll present a selection of system calls that are likely to be the most useful to application and system programmers.
Most of these system calls are declared in