In the Context of Linux, what is a System Call?

Question
In the context of Linux, what is a system call?

Answer
A system call is a special OS function with a human-readable name (according to page 11 of Sobell's A Practical Guide to Fedora and RedHat Enterprise Linux). Such a function allows for programs to interact with the kernel (according to page 11 of Sobell's A Practical Guide to Fedora and RedHat Enterprise Linux). The kernel facilitates getting resources or interacting with the devices (according to page 11 of Sobell's A Practical Guide to Fedora and RedHat Enterprise Linux).

Examples of system calls include exec(), fork(), gethostbyname(), isatty(), setlocale(), sleep(), strtok(), and write(). (All of these except write() were taken from page 1333 of Sobell's A Practical Guide to Fedora and RedHat Enterprise Linux).

A system call is traditionally made from userspace into kernelspace (according to IBM). To learn more about the differences between userspace and kernelspace, see this posting "Can the Kernel Access Hardware Directly?"

A useful way to debug system calls is with the strace command.

To view the man page of system calls, from a Linux command prompt use man 2 nameofsystemcall (where "nameofsystemcall" is the system call you want to read about).

The man syscalls page says "[t]he system call is the fundamental interface between an application and the Linux kernel."

To learn more about system calls (such as exit, ulimit, umask, chown, mount, and nice), run this command: man syscalls

Using man syscall is also helpful.

Leave a comment

Your email address will not be published. Required fields are marked *