CSOS & ConcurrencyDiagramIntermediate
System Call
KO: 시스템 콜 (System Call)·EN: System Call·JA: システムコール·Syscall
The controlled gateway through which user-space programs transition into kernel mode to request privileged OS services like file I/O, networking, and memory allocation
Table of Contents
Structure Diagram
System Call User Mode ↔ Kernel Mode Transition Cycle
1/41. User App (Ring 3)— Call libc wrapper
Call libc wrapperQuick Answer
What is System Call?
The controlled gateway through which user-space programs transition into kernel mode to request privileged OS services like file I/O, networking, and memory allocation. It is a core concept in OS & Concurrency within CS.
Core Principles
Modern CPUs separate execution into unprivileged User Mode (Ring 3) and privileged Kernel Mode (Ring 0). A System Call (Syscall) is the strictly controlled boundary through which user programs ask the OS kernel to perform privileged actions (disk I/O, networking, process creation, memory mapping).
- Mechanics: Calling a
libcwrapper executes a CPUsyscallinstruction, traps into the kernel, validates arguments and permissions, performs the work, and returns viasysret. - Cost: Mode transitions, register saves, and security mitigations make syscalls orders of magnitude slower than normal function calls.
Practical Takeaways
- Batch I/O with user-space buffers: Calling
write()one byte at a time triggers massive syscall overhead; always buffer (bufio,BufferedWriter). - Zero-Copy &
io_uring:sendfile()avoids copying data through user space, while Linuxio_uringbatches hundreds of async I/O operations via shared ring buffers with near-zero syscalls. - Debug black boxes with
strace: Tracing syscalls instantly reveals missing files, hung sockets, or permission errors.
Notable Examples
- Core POSIX Syscalls:
open,read,write,mmap,fork,epoll_wait. - vDSO: Serving high-frequency calls like
clock_gettime()in user space without trapping. - Container Hardening (
seccomp): Blocking dangerous syscalls inside Docker/Kubernetes sandboxes.