x
Loading
 Loading
Hello, Guest | Login | Register

The Design of an In-Kernel Server

In last month’s column, we took a look at the practice of invoking system calls from within kernel code. This month’s column will deal with how a complete network server can be implemented as a kernel thread. The sample code shown throughout this column implements a simplified TFTP server. See the Features of the Sample Code sidebar, pg. 80, for more information.

In last month’s column, we took a look at the practice of invoking system calls from within kernel code. This month’s column will deal with how a complete network server can be implemented as a kernel thread. The sample code shown throughout this column implements a simplified TFTP server. See the Features of the Sample Code sidebar, pg. 80, for more information.

Normally, you shouldn’t bring user-space processes into kernel space, but there are times when, for performance or size reasons, this may be a good idea. The former reason is what led to kHTTPd. The latter may be relevant to avoiding the size overhead of a user-space application (based on libc, for example) in small-embedded systems devoted to a single task.

This column refers to the kernel-based Web server released in version 2.4.0-test9 of the kernel, which can be found in the net/khttpd directory of the source tree for that release. This is the kHTTPd program by Arjan van de Ven, not the Tux reimplementation by Ingo Molnar. While the latter program exhibits higher performance, it is also a bit more complex.

Kernel Threads

The first step a programmer must take in running a server in kernel space is to fork a process. To create a new thread, you must call the function kernel_thread. Since this is usually performed by the initialization function of a kernel module, the programmer must also detach the thread from the context of the insmod or modprobe command…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace