- The system call helps in availing the service provided by the kernel to the userland process.
- Common system calls are: read, write, socket, etc.
Working Principle:
- Execution of system call is an example of Software Interrupt where the control of execution is passed to kernel space code that is to appropriate system call system routine.
- There is a special number associated with each system call and the user space program puts this number in a register and is passed as an argument to system calls.
- System call numbers correspond to an entry in a table called the system call table.
- Each entry is like a function pointer that holds an address of a function that the CPU will begin executing when that interrupt is received.
- Before the control is passed to the called routines, the current context of the process like registers content, program counter which holds the next instruction to be executed is saved onto the stack.
- Once the service routine is done, the register content is overwritten with the saved context and starts the normal execution in the user space.
System call Interface Layer:
- It serves as an interface between system calls and the underlying operating system.
- The System call interface layer provides a trap handler that is invoked whenever a system call API is invoked.
- As per the system call API and its rules, the trap handler with the help of the system call table (also located in the system call interface layer) will invoke the appropriate system call system routine in the appropriate sub-system of the kernel.
Diag-1: System call working

Related Post
Categories: Operating system (OS)
Leave a Reply