How System Calls Work in Linux?

Filed under
HowTos

Every GNU/Linux programmer here reading this article must have used system calls to code their programs. GNU/Linux programming is incomplete without system calls. System calls are initiated by software interrupts. Before we delve into that, however, let’s define system calls.

A system call is the mechanism used by an application program to request service from the operating system, or more specifically, the operating system kernel.

Modern processors execute instructions in different privilege states. In system, where just two levels are defined (as in i386), these states are known as user mode and supervisor mode. These privilege levels are defined so that an operating system restrict can control the operations performed by the program. Controlling is done for reasons of security and stability. The kernel of the operating system should always run in privilege mode since it needs to do some operations. Such operations include accessing hardware devices, enabling and disabling interrupts, changing privileged processor state, and accessing memory management units.

Now with this setup of an operating system (with two modes of execution (considering only i386 architecture only)), we need a mechanism to transfer control safety from lesser privileged modes to higher privileged modes.

Full Story.