What is a system call, and what happens when one is executed?
Interview preparation resource from Gate Smashers.
A system call is the controlled interface through which a user program requests a kernel service. The request traps into the kernel, is validated and executed, and then returns a result or error to the process.

A program normally calls a library function such as read(), open() or fork(). The wrapper places the system-call number and arguments where the operating system expects them, then executes a special trap instruction.
The CPU saves the current user context, changes privilege level and jumps to the kernel's system-call handler. The kernel checks the call number, permissions, addresses and arguments before performing the work. It then stores the return value, restores user execution and continues after the original call.
The important interview point is that a system call is not an ordinary function call. It crosses a protection boundary and therefore requires validation and a privilege transition. This extra work makes it safer, but also more expensive than calling a function entirely within user space.
