System Calls: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Combuster (talk | contribs)
styling up things a bit
added link discussed on forums
Line 24: Line 24:
While the developper can trigger manually the system call, it is probably a good idea to provide a library to encapsulate such a call. Therefore you wil be able to switch the system call technique without impacting the user applications.
While the developper can trigger manually the system call, it is probably a good idea to provide a library to encapsulate such a call. Therefore you wil be able to switch the system call technique without impacting the user applications.


==Related Threads==
==See Also==
===Threads===


* [[Topic:13186|System call implementation]]
* [[Topic:13186|System call implementation]]


==External links==
===External links===


* http://en.wikipedia.org/wiki/System_call
* http://en.wikipedia.org/wiki/System_call
Line 35: Line 36:
* L4 strategy: http://www.pagetable.com/?p=9
* L4 strategy: http://www.pagetable.com/?p=9
* Linux syscalls: http://manugarg.googlepages.com/systemcallinlinux2_6.html
* Linux syscalls: http://manugarg.googlepages.com/systemcallinlinux2_6.html
* http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/x86-system-calls.html


[[Category:OS theory]]
[[Category:OS theory]]

Revision as of 21:07, 13 August 2007

This page is a work in progress.
This page may thus be incomplete. Its content may be changed in the near future.

System Calls are used to call a kernel service from user land. The goal is to be able to switch from user mode to kernel mode, with the associated privileges. Provided system calls depends on the nature of your kernel.

Available Methods

System Calls via Interrupts

The most common way to implement system calls is using a software interrupt. It is probably the most portable way to imlement system call. Linux traditionaly use interrupt 0x80 for this purposes.

System Calls via Sysenter/Sysexit (Intel)

On Intel CPU, starting from the Pentium II, a new instruction pair sysenter/sysexit has appeared. It allows a faster switch from user mode to kernel mode, by limiting the overhead of changing mode.

A similar instruction pair has been created by AMD: Syscall/Sysret. However the behaviour of these instructions are different from Intel's.

System Calls via Trap

Some OSes implement system calls by triggering a CPU Trap in a determined fashion such that they can recognize it as a system call. This solution is adopted on some hardware by Solaris, by L4, and probably others.

For example, L4 use a "LOCK NOP" instruction on x86. Since it is not permitted to perfrom a lock on the "NOP" instruction a trap is triggered. The problem with this approach is that there is no guarantee the "LOCK NOP" will have the same behavior on futur x86 CPU. They should probably have used the "UD2" instruction, since it is defined for this purposes.

Strategies Conlusion

The system call strategy depends on the platform. You may want to use different strategy depending on the architecture, and even switch strategy depending on the hardware performance.

On the user land side

While the developper can trigger manually the system call, it is probably a good idea to provide a library to encapsulate such a call. Therefore you wil be able to switch the system call technique without impacting the user applications.

See Also

Threads

External links