I seen all system calls (say x) are related with a another call as sys_x(): Ex: fork and sys_fork(),open() and sys_open() etc.
What is significance of these sys_x() calls? Where we can use these calls?
What is significance of these sys_x() calls?
As the name indicates, these are the actual syscalls being executed in kernel mode.
You see, when you call fork(2) or open(2) from your application, you are not invoking a raw syscall directly; instead, you're invoking glibc's wrappers that know how to call the actual syscall. This indirection step is needed because syscall invocation is architecture specific, so the details are hidden in glibc.
Where we can use these calls?
You don't. For one, sys_fork() is Linux-specific; other UNIX variants are not required to (and probably they don't) implement a sys_fork() function. The exact functions inside the kernel that deal with forking are system dependent. It just so happens that Linux has a function called sys_fork(), sys_open(), etc.
For example, in the case of fork(2), in Linux the flow is more or less like:
fork() -> glibc wrapper -> raw syscall invocation -> transition to kernel mode -> syscall lookup -> sys_fork() -> do_fork().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With