System calls and its working

  • 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

How does a system call work - Stack Overflow

Related Post

Categories: Operating system (OS)

6 replies


  1. Introduction: Operating System - Tech Access Info
  2. Introduction to Kernel - Tech Access Info
  3. Structure of Linux Operating System - Tech Access Info
  4. Types of Threads - Tech Access Info
  5. Index of Operating System - Tech Access
  6. User Level Threads - Tech Access

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: