Open main menu

CDOT Wiki β

Changes

Syscalls

781 bytes added, 15:01, 16 September 2014
no edit summary
[[Category:Assembly Language]]
The system call (''syscall'') mechanism is used by applications to access kernel services. The userland (application/non-kernel) program loads certain registers designating the system service (syscall) desired and the arguments to that syscall, then invokes a software interrupt or exception request which transfers control to the operating system kernel. Note that switching to kernel mode requires a change of processor mode (sometimes call the privilege level or exception level), because the kernel has access to instructions, memory structures, memory areas, and devices which userland programs can't access. The syscall numbers may vary between architectures, and the method used to invoke syscalls is architecture-specific. The processor modes and activity involved in a userland-to-kernel switch also vary by architecture.
High-level languages will wrap the syscall interface in basic wrappers or more advanced mechanisms. For example, in C, the ''write'' syscall can be accessed through the <code>write()</code> wrapper, or through more complex functions such as <code>printf()</code>. [[Assembly Language|Assembly language]] programs will often access syscalls directly.
== Syscall Mechanism ==
To invoke a syscallin your own code, load the syscall number and arguments into the appropriate registers, and then invoke the platformarchitecture-specific syscall mechanism., using the details below:
=== x86 32-bit ===