Next: Compiling and Loading
Up: Kernel Modules Versus Applications
Previous: Concurrency in the Kernel
Contents
A Few Other Details
- Applications are laid out in virtual memory with a very large stack area. The stack, of course, is used to hold the function call history and all automatic variables created by currently active functions.
- The kernel, instead, has a very small stack; it can be as small as a single, 4096-byte page. Your functions must share that stack with the entire kernel-space call chain. Thus, it is never a good idea to declare large automatic variables; if you need larger structures, you should allocate them dynamically at call time.
- Often, as you look at the kernel API, you will encounter function names starting with a double underscore (). Functions so marked are generally a low-level component of the interface and should be used with caution. Essentially, the double underscore says to the programmer: "If you call this function, be sure you know what you are doing."
- Kernel code cannot do floating point arithmetic. Enabling floating point would require that the kernel save and restore the floating point processor's state on each entry to, and exit from, kernel space (at least, on some architectures). Given that there really is no need for floating point in kernel code, the extra overhead is not worthwhile.
Next: Compiling and Loading
Up: Kernel Modules Versus Applications
Previous: Concurrency in the Kernel
Contents
Cem Ozdogan
2007-05-16