What exactly happens during a System Call? Walk through the transition from user space to kernel space.
Last updated
The program (often via a library wrapper like glibc) puts the system call number and arguments in registers, then executes a trap instruction (e.g.
syscall) that switches the CPU to kernel mode.The kernel handler uses the call number to index the system call table, validates the arguments, and performs the privileged work.
The result goes in a register and the CPU returns to user mode after the trap. This boundary stops user code from touching hardware or kernel memory directly.