- System call
computing, a system call is the mechanism used by an application program to request service from the kernel.
A system call is a request made by any arbitrary program to the kernel for performing tasks -- picked from a predefined set -- which the said program does not have required permissions to execute in its own flow of execution. System calls provide the interface between a process and the kernel. These calls are generally available as assembly language instructions and they are usually listed in the various manuals used by the assembly-language programmers.Most operations interacting with the system require permissions not available to a user level process, i.e. any I/O performed with any arbitrary device present on the system or any form of communication with other processes requires the use of system calls.
The fact that improper use of the system can easily cause a system crash necessitates some level of control. The design of the microprocessor architecture on practically all modern systems (except some embedded systems) offers a series of "
privilege levels" -- the (low) privilege level in which normal applications execute limits the address spaceof the program so that it cannot access or modify other running applications nor the kernel itself. It also prevents the application from using any system devices (e.g. the frame bufferor networkdevices). But obviously any normal application needs these abilities; thus it can call the kernel. The OS executes at the highest level of privilege and allows the applications to request services via system calls, which are often implemented through interrupts. If allowed, the system enters a higher privilege level, executes a specific set of instructions which the interrupting program has no direct control over, then returns control to the former flow of execution. This concept also serves as a way to implement security.
With the development of separate operating modes with varying levels of privilege, a mechanism was needed for transferring control safely from lesser privileged modes to higher privileged modes. Less privileged code could not simply transfer control to more privileged code at any arbitrary point and with any arbitrary processor state. To allow it to do so would allow it to break security. For instance, the less privileged code could cause the higher privileged code to execute in the wrong order, or provide it with a bad stack.
The library as an intermediary
Generally, operating systems provide a library that sits between normal programs and the kernel, usually an implementation of the C library (libc), such as
glibc. This library handles the low-level details of passing information to the kernel and switching to supervisor mode, as well as any data processing and preparation which does not need to be done in privileged mode. Ideally, this reduces the coupling between the kernel and the application, and increases portability.
exokernelbased systems, the library is especially important as an intermediary. On exokernels, OSes shield user applications from the very low level kernel API, and provide abstractions and resource management.
Examples and tools
Unix-based and POSIX-based systems, popular system calls are open, read, write, close, wait, exec, fork, exit, and kill. Many of today's operating systems have hundreds of system calls. For example, Linuxhas 319 different system calls. FreeBSDhas about the same amount (almost 330).
Tools such as strace and truss allow a process to execute from start and report all system calls the process invokes, or can attach to an already running process and intercept any system call made by said process if the operation does not violate the permissions of the user. This special ability of the program is usually also implemented with a system call, e.g. the GNU/Linux "strace" is implemented with i.a. "ptrace()".
Implementing system calls requires a control transfer which involves some sort of architecture specific feature. A typical way to implement this is to use a software
interruptor trap. Interrupts transfer control to the kernel so software simply needs to set up some register with the system call number they want and execute the software interrupt.
RISCprocessors this is the only feasible implementation, but CISC architectures such as x86support additional techniques. One example is SYSCALL/SYSRET which is very similar to SYSENTER/SYSEXIT (the two mechanisms were created by Intel and AMD independently, but do basically the same thing). These are "fast" control transfer instructions that are designed to quickly transfer control to the kernel for a system call without the overhead of an interrupt. Linux2.5 began using this on the x86, where available; formerly it used the INT instruction, where the system call number was placed in the EAX register before interrupt 0x80 was executed. [cite web |url=http://kerneltrap.org/node/531 |title=Linux 2.5 gets vsyscalls, sysenter support |accessdate=2008-01-01 |author=Anonymous |date=2002-12-19 |work= KernelTrap]
x86mechanism is called a call gateand is a way for a program to literally call a kernel function directly using a safe control transfer mechanism the kernel sets up in advance. This approach has been unpopular, presumably due to the requirement of a far call which uses x86 memory segmentationand the resulting lack of portability it causes, and existence of the faster instructions mentioned above.
* [http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html Linux system calls] - system calls for
Linux kernel2.2, with IA32 calling conventions
* [http://www.tldp.org/LDP/khg/HyperNews/get/syscall/syscall86.html How System Calls Work on Linux/i86]
* [http://manugarg.blogspot.com/2006/07/sysenter-based-system-call-mechanism.html Sysenter Based System Call Mechanism in Linux 2.6]
* [http://www.ibm.com/developerworks/linux/library/l-system-calls Kernel command using Linux system calls] - IBM developerWorks
* [http://tldp.org/HOWTO/html_single/Implement-Sys-Call-Linux-2.6-i386 HOWTO for Implementing a System Call on Linux 2.6] - Amit Choudhary
Wikimedia Foundation. 2010.
Look at other dictionaries:
System Call — Ein Systemaufruf, auch Systemcall (von engl. system call) oder kurz Syscall, ist in der Computertechnik eine von Anwendungsprogrammen benutzte Methode, um vom Betriebssystem bereitgestellte Funktionalitäten auszuführen. Inhaltsverzeichnis 1… … Deutsch Wikipedia
system call — noun an instruction that interrupts the program being executed and passes control to the supervisor • Syn: ↑supervisor call instruction • Hypernyms: ↑call … Useful english dictionary
Open (system call) — For most file systems, a program initializes access to a file in a filesystem using the open system call. This allocates resources associated to the file (the file descriptor), and returns a handle that the process will use to refer to that file … Wikipedia
Close (system call) — For most file systems, a program terminates access to a file in a filesystem using the close system call. This flushes buffers, updates file metadata (which may include and end of file indicator in the data), de allocates resources associated… … Wikipedia
Splice (system call) — splice() is a system call that copies data between a file handle and a pipe, or between a pipe and user space. It does so without actually copying the data, in contrast to other data copying techniques, thereby improving I/O performance.Workings… … Wikipedia
clone (Linux system call) — clone() is a system call on the Linux kernel related to multithreading. In practice, one should try to avoid calling clone() directly, but instead use a threading library (such as pthreads) which use clone() when starting a thread (such as during … Wikipedia
Clone (Linux system call) — clone() is a system call on the Linux kernel related to multithreading.The syntax for calling clone under a Linux program is: #include int clone (int (*fn) (void *), void *child stack, int flags, void *arg);clone creates a new thread that starts… … Wikipedia
Call — may refer to: NOTOC Technology* Call (telecommunications) * Telephone call * Computer assisted language learning, a concept in language education * System call, the mechanism used by an application program to request service from the operating… … Wikipedia
Call a Pizza — Franchise GmbH Rechtsform Franchise Gründung 1985 Sitz Berlin Leitung Thomas Wilde Umsatz … Deutsch Wikipedia
Call gate — A call gate (or callgate) is a mechanism in Intel s x86 architecture for changing the privilege level of the CPU when it executes a predefined function call using a CALL FAR instruction. Overview Call gates are intended to allow less privileged… … Wikipedia