Changes

Jump to: navigation, search

Syscalls

675 bytes added, 00:48, 20 January 2017
no edit summary
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 registers as well as the method used to invoke syscalls are architecture-specific. The processor modes and activity involved in a userland-to-kernel switch also vary by architecture.
High-level languages wrap the syscall interface in basic wrappers or more advanced mechanisms. For example, in C, the ''write'' syscall can be accessed through the generic <code>syscall</code> wrapper, 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 ==
#define __NR_write 1
 
You can use the <code>ausyscall</code> utility to from the Linux command line to determine the number for a given syscall on the particular platform:
 
$ ausyscall x86_64 write
write 1
pwrite 18
writev 20
pwritev 296
process_vm_writev 311
$ ausyscall aarch64 write
write 64
writev 66
pwrite 68
pwritev 70
process_vm_writev 271
 
Note that the syscall table is searched by name, and in the examples above the text "write" matches five different syscalls. The architecture defaults to the current platform if not specified.
=== Syscall arguments and return values ===

Navigation menu