---
title: "System call"
url: https://www.daytona.com/compute-glossary/kernel/system-call
---

# System call

Part of the [Compute Glossary](https://www.daytona.com/compute-glossary.md), section [Kernel](https://www.daytona.com/compute-glossary/kernel.md).

Also called Syscall.

A system call is the interface through which a program in user mode asks the [kernel](https://www.daytona.com/compute-glossary/kernel/kernel.md) to do work that only the kernel may do. Everything a [process](https://www.daytona.com/compute-glossary/kernel/process.md) does beyond pure computation passes through one. Pure computation, such as adding numbers in registers, runs on the processor without the kernel. Even ending a program takes a system call, as does asking for more memory.

A program that wants to read a file or send data over the network cannot reach the disk or the network card itself. It makes a system call, and the kernel decides whether to allow the request. The program never touches the device, so the kernel can share it safely among many programs. The same check also enforces who may read which file.

Because every request to the kernel goes through a system call, the set of calls a program can make is its attack surface on the kernel. [Seccomp](https://www.daytona.com/compute-glossary/kernel/seccomp.md) filters shrink that set, and a [virtual machine](https://www.daytona.com/compute-glossary/virtualization/virtual-machine.md) sends the calls of a guest to a kernel of its own. In a guest, a bug reached through a system call compromises only the guest kernel. The hypervisor still stands between that kernel and the host.

## Entry into the kernel

Entry into the kernel is the switch a system call makes from user mode to kernel mode. The program places a number that identifies the call, and its arguments, in registers, then executes a special instruction. Which register holds what is fixed for each architecture, so the kernel always knows where to look. Before dedicated instructions existed, programs entered the kernel through a software interrupt, which was slower.

The processor switches to kernel mode and jumps to a fixed entry point. The kernel looks up the handler for that number, carries out the request, and returns a result or an error code to user mode. A call that has to wait, such as a read from a slow disk, puts the thread to sleep while the kernel runs other work. Interfaces such as io_uring let a program queue many requests and collect the results without one call per request.

A system call costs far more than a function call, because of the switch and the mitigations for speculative-execution attacks. Linux avoids the switch for a few read-only calls, such as reading the clock, by mapping a small piece of kernel code called the vDSO into every process. Batching requests is the usual way for a program to pay that cost less often. A server that handles many small messages can spend more time entering and leaving the kernel than doing its own work.

| **Architecture** | **Description**                                         |
| ---------------- | ------------------------------------------------------- |
| **x86-64**       | Programs enter the kernel with the syscall instruction. |
| **AArch64**      | Programs enter the kernel with the svc instruction.     |

## Wrappers

Wrappers are ordinary library functions that make system calls for a program. The C library wraps most calls in functions of the same name, and higher-level languages wrap those again. The wrapper puts the arguments where the kernel expects them and turns an error into a value the program can check. Go on Linux is an exception, since its runtime makes system calls directly without the C library.

Few programs therefore make system calls by hand. A single line of application code can turn into many system calls, and tracing tools such as strace make them visible on Linux. Printing a line, for example, may make no call at all until the buffer of the library fills. Tracing shows where a slow program waits on the kernel.

Wrappers also hide the differences between kernels and architectures from application code. The same program source can then be built for many systems without changes to its calls. The POSIX standard defines many of these functions, so they behave alike across Unix-like systems. Windows goes further and keeps its system calls private, so programs reach the kernel only through its libraries.

## Interface stability

Interface stability is the promise that the calls a kernel offers keep working across versions. On Linux, a call that worked years ago keeps working, which is why old binaries still run on new kernels. Other systems, such as macOS and OpenBSD, promise stability only for the C library and may change the calls beneath it. Linux has no C library of its own, which is why its kernel keeps the promise itself.

The interface is still not the same everywhere. The set of calls and their numbers differ by [instruction set architecture](https://www.daytona.com/compute-glossary/hardware/cpu-architecture.md), so a binary built for one cannot use the calls of another. Even on one architecture, a call can exist in several versions, because a newer call is added rather than the old one changed. Old calls stay in place beside the new ones, so the list only grows.

Stability also lets other software stand in for the kernel. The gVisor runtime answers the system calls of a sandboxed program in a user-space kernel of its own, which works because the interface it copies does not change. The first Windows Subsystem for Linux worked the same way, answering the calls of Linux programs on top of the Windows kernel. Any call such a layer gets wrong shows up as a program that fails there but works on Linux.

## Related terms

- [Kernel](https://www.daytona.com/compute-glossary/kernel/kernel.md)
- [Process](https://www.daytona.com/compute-glossary/kernel/process.md)
- [Seccomp](https://www.daytona.com/compute-glossary/kernel/seccomp.md)
- [CPU architecture](https://www.daytona.com/compute-glossary/hardware/cpu-architecture.md)
- [Isolation](https://www.daytona.com/compute-glossary/sandboxes/isolation.md)
