

What prevents user programs from performing these actions themselves? User programs (like your editor, terminal, ssh daemon, etc) need to interact with the Linux kernel so that the kernel can perform a set of operations on behalf of your user programs that they can’t perform themselves.įor example, if a user program needs to do some sort of IO ( open, read, write, etc) or modify its address space ( mmap, sbrk, etc) it must trigger the kernel to run to complete those actions on its behalf. User programs, the kernel, and CPU privilege levels X86-64 in this blog post will refer to 64bit Intel and AMD CPUs that are based on the x86 architecture.

Other kernel versions will be similar, but the exact line numbers, organization of code, and file paths will vary. You are interested in the Linux kernel, version 3.13.0.
DISPATCH CALLS CODE
The discussion about the methods may be useful for people using other systems, but the code samples below contain CPU-specific code.
DISPATCH CALLS SOFTWARE
Prerequisite information Hardware and software Glibc provides wrapper code which abstracts you away from the underlying code which arranges the arguments you’ve passed and enters the kernel.īefore we can dive into the details of how system calls are made, we’ll need to define some terms and examine some core ideas that will appear later. You simply include the appropriate header file and make the call as if it were a normal function. There are several different ways for user programs to make system calls and the low-level instructions for making a system call vary among CPU architectures.Īs an application developer, you don’t typically need to think about how exactly a system call is made. You can find a list of system calls by checking the man page for syscalls(2). Programs use system calls to perform a variety of operations such as: creating processes, doing network and file IO, and much more.

System calls are how a program enters the kernel to perform some task. When you run a program which calls open, fork, read, write (and many others) you are making a system call.
