One of the most renowned features of Unix is the clear distinction between what occurs in “kernel space” and what occurs in “user space.” This column will describe how to invoke kernel system calls from within kernel code. This is a first step towards understanding how to build a kernel-resident application, such as a high-performance Web server.
Figure One: The steps involved in performing a call to read() from a user space function.
One of the most renowned features of Unix is the clear distinction between what occurs in “kernel space” and what occurs in “user space.” This column will describe how to invoke kernel system calls from within kernel code. This is a first step towards understanding how to build a kernel-resident application, such as a high-performance Web server.
System Calls: the Facts
System calls have always been the means through which user space programs can access kernel services. The Linux kernel implementation is able to break the distinction between kernel space and user space by allowing kernel code to invoke system calls as well. This allows the kernel to perform tasks that have traditionally been reserved for user applications, while retaining the same programming model.
The benefit of this approach is performance; the overhead of scheduling a user application, and for that application to invoke system calls back into the kernel, makes it undesirable for some services to be performed in user space. For example, a high-performance Web server may wish to reside in the kernel for increased throughput and lower latency. However, there is also a safety tradeoff; implementing complex…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: