Call

system call

In computing, a system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on.

流程:

  • Application program makes a system call. When I write the program in ARM. I used SWI instruction. SWI means software interrupt exception. SWI will cause an interrupt. So the kernel will handle this interrupt. The handler is called SWI hander.
  • Stack is used to pass these arguments to the function in the kernel.
  • Each system call has a unique call number which is used by kernel to identify which system call is invoked.
  • Now the SWI handler executes a specific instruction (int 0x80). This instruction causes the processor to switch from 'User Mode' to 'Kernel Mode'
  • kernel invokes system_call() routine
  • This function saves register values onto kernel stack and does some validations like verifying system call number etc.
  • A map of system call number as key and the appropriate system call as value exists. This is called system_call_table. The handler uses this table to invoke appropriate system call service routine. It also validates the arguments if present.
  • After proper validations, the service routine performs required actions. After all these actions, service routine returns status of execution to user mode call.

Children
  1. Execve
  2. Fork