System Calls vs. Library Functions

System Calls

The kernel is not a library ⟶ no direct function calls, but rather System Calls.

  • Entry points into the kernel

  • Every system call has a unique number and a fixed set of parameters and registers (ABI)

  • Changes context from user mode to kernel mode

  • Implementation is CPU specific (software interrupt …)

  • Numbers, parameters, etc. are Linux specific

  • ⟶ “kernel acts on behalf of a process”

System Calls And The C-Library

System calls are never used directly by a program …

syscall wrapper: write()
#include <unistd.h>
int main() {
    write(1, "hallo\n", 6);
    return 0;
}
../../../../../../_images/syscalls-libc.svg

Library Function Or System Call?

Distinction is not always clear ⟶ manual pages

System calls (man -s 2 ...)

No system calls (man -s 3 ...)

Manual Pages

man [section] name

For example: man man

  1. User Commands

  2. System Calls

  3. C Library Functions

  4. Devices and Special Files

  5. File Formats and Conventions

  6. Games et. Al.

  7. Miscellanea

  8. System Administration tools and Daemons