arka
arka

Reputation: 438

Difference between System call and System call service routines

I am going through how actually system calls works and learned a term system call service routine. I am confused what is difference between system call and system call service routine ?

For example, on Linux system man syscalls lists all the system calls there is a system call execve() to execute a new program specified by pathname. Later I found that it actually calling the system call service routine sys_execve (execve() has the system call number 11 (__NR_exevce). Thus, in the sys_call_table vector, entry 11 contains the address of sys_execve()).

What is __NR_exevce ? Where I can find sys_call_table vector ? I also found that on linux, system call service routines typically have names of the form sys_xyz(), where xyz() is the system call.

Upvotes: 2

Views: 1007

Answers (1)

KamilCuk
KamilCuk

Reputation: 140990

System call is something abstract. It's a way of communication between user-space to kernel, by passing specific data to specific registers specific to a platform.

Kernel is a program. Linux Kernel is written in C programming language.

Here, "system call service routine" is the name of the function in C programming language that handles a specific system call.

So user space program calls system call number __NR_execve. On x86 architecture, the user space program places the number 59 in eax register and then executes instruction int 0x80. Specific system call handling routines are executed in the kernel, which cause the function sys_execve() in kernel to be executed.

What is __NR_exevce ?

A macro in C programming language that provides platform-agnostic access to the system call number associated with execve system call. It allows writing portable across all Linux platforms programs written in C programming language that automatically during compilation choose the correct platform specific system call number. On arm __NR_execve is 11, but on x86 it is 59, etc.. See https://chromium.googlesource.com/chromiumos/docs/+/master/constants/syscalls.md#Cross_arch-Numbers

Where I can find sys_call_table vector

In the kernel sources. Search for it on elixir. https://elixir.bootlin.com/linux/latest/ident/sys_call_table

Upvotes: 4

Related Questions