A system call, sometimes called a kernel call, is a request by an active process for a service performed by the kernel (i.e., the core of the operating system), such as input/output (I/O) or process creation (i.e., creation of a new process). A process is an executing (i.e., running) instance of a program, and an active process is one that is currently progressing in the CPU (central processing unit), as contrasted with processes that are waiting for their next turns in the CPU. I/O is any movement of information to or from the combination of the CPU and memory.
A list of all registered system calls is maintained in the system call table, which assigns each a unique number. The numbers cannot be changed or recycled. Different operating systems and different versions of an operating system for use on different types of processors have different numbers.
Processes do not refer to system calls by name, but rather by their system call number. That is, a system call number is an argument (i.e., input information) that a process must pass to the kernel in order to identify the requested system call. Additional arguments are also usually passed at the same time.
Programmers usually do not need to be concerned with system calls and system call numbers. This is because there are functions in glibc, the GNU project's implementation of the Standard C library, to do virtually everything that system calls do. A library is a collection of subprograms that any programmer can employ to reduce the amount of complex and repetitive code that has to be written for individual programs. The glibc functions work by making system calls themselves. For example, the __NR_rename system call, whose system call number is 38, is used to rename files, but it is not necessary to know about it because the glibc's rename function can be used instead.
In the case of Red Hat Linux 9 for Intel-compatible processors, the system call numbers are listed in the file /usr/include/asm/unistd.h, and they can be viewed with a command such as
cat is commonly used to read the contents of text files. As the output can more than fill a single display screen, it is convenient to pipe (i.e., transfer) it to the less command to allow it to be read one screenful at a time. The list of system calls and their numbers begins as follows:
#define __NR_exit 1 #define __NR_fork 2 #define __NR_read 3 #define __NR_write 4 #define __NR_open 5 #define __NR_close 6 #define __NR_waitpid 7 #define __NR_creat 8 #define __NR_link 9 #define __NR_unlink 10 #define __NR_execve 11 #define __NR_chdir 12 #define __NR_time 13 #define __NR_mknod 14 #define __NR_chmod 15 #define __NR_lchown 16
When a programmer writes a new system call, its name (which is always prefixed by __NR_) and a new system call number for it are added to this table.
In order for the kernel to associate each system call number with its corresponding service routine, the kernel makes use of a system call dispatch table, which is stored in the sys_call_table array.
Created June 21, 2005.