System call
In computing, system call is the mechanism used by an application to request a service from the operating system.
Mechanism
System calls commonly use a special CPU instruction that causes the processor to pass control to privileged code (usually the kernel), previously specified. This allows the privileged code to specify where it is to be connected to as well as the state of the processor.
When a system call is invoked, the execution of the calling program is interrupted and its data is saved, usually on its PCB (Process Control Block), so that it can continue executing later. The processor then begins executing the low-privilege code instructions to perform the required task. When it ends, it returns to the original process, and continues its execution. The return to the requesting process is not necessarily immediate, it depends on the execution time of the system call and the CPU scheduling algorithm.
Libraries as intermediaries
Generally, operating systems provide libraries that link user programs and the rest of the operating system, usually a C runtime library such as GNU's glibc or Microsoft's C library. This library handles, among other things, the low-level details of transferring information to the kernel and switching to supervisor mode, as well as any data processing or tasks that need to be performed in supervisor mode. Ideally, this reduces the dependency between the operating system and the application and software, and increases its portability.
Examples and tools
In operating systems under the POSIX standard or similar, some widely used system calls are open, Read (system call), write, close, wait, exec, fork, exit and kill. Current operating systems have hundreds of calls, for example Linux 2.x and FreeBSD have over 300.
Typical Implementations
The implementation of system calls requires transfer control that involves specific features of the processor architecture. A typical way to implement is to use a software interrupt. Linux uses this implementation on the x86 architecture.
For RISC architecture processors, this is the only way, but CISC architectures like x86 support additional techniques. An example is SYSCALL/SYSENTER.
Contenido relacionado
Minesweeper
Annex: XML dialects
Roaming