Does the libc function strcpy () call any syscall?

I want to know if there is any libc function that does not call any syscall ()? For example, for the libc function "strcpy ()", is there any syscall (let's consider all possible Linux systems).

+4
source share
2 answers

syscalls somewhat resembles an interface from user space (the place where your program is running) to the kernel ground. They are necessary when you do something that only the kernel can, for example, communicate with equipment (for example, read bytes from a network card, start a process, even allocating memory via malloc (using brk ), etc.).

Userland functions, such as strcpy , on the other hand, are not indented to make system calls. They do not need special privileges to do what they do, they just work with the process memory on the user's land.

A serious decrease in performance is introduced as system calls (changing modes from the user to the kernel ground and vice versa is expensive), since those that are often called functions like strcpy do not make sense from the design point of view and are unlikely to be seen.

+4
source

System calls are very difficult because they imply that the context switches to the kernel. Therefore, for a simple library function such as strcpy (whose functionality is actually equivalent to while(*d++ = *s++) , but potentially optimized for architecture), a system call does not make sense.

Please note that a page error during copying can lead to a kernel context switch and a system call, but this will not be the result of strcpy calling the system call directly.

+4
source

Source: https://habr.com/ru/post/1438202/


All Articles