Obtaining the Kernel Source www kernel org http
Obtaining the Kernel Source www. kernel. org http: //lxr. free-electrons. com/
The Kernel Source Tree Directory lib Description Architecture-specific source Crypto API Kernel source documentation Device drivers The VFS and the individual file systems Kernel headers Kernel boot and initialization Interprocess communication code Core subsystems, such as the scheduler Helper routines mm Memory management subsystem and the VM net Networking subsystem Scripts used to build the kernel Linux Security Module Sound subsystem Early user-space code (called initramfs) arch crypto Documentation drivers fs include init ipc kernel scripts security sound usr
Lines of code
Different Natures The kernel does not have access to the C library. The kernel is coded in GNU C. (not in ANSI C) The kernel lacks memory protection like user-space. The kernel cannot easily use floating point. The kernel has a small fixed-size stack. Because the kernel has asynchronous interrupts, is preemptive, and supports SMP, synchronization and concurrency are major concerns within the kernel. • Portability is important. • • •
Different Natures • NO libc support – There are multiple reasons for this, including some chicken-and-the-egg situations, but the primary reason is speed and size (upcall? ). – Many of the usual libc functions have been implemented inside the kernel. • For example <linux/string. h>
Different Natures • Inline Assembly – The asm() compiler directive is used to inline assembly code. • Branch Annotation if (unlikely(foo)) { /*. . . */ } if (likely(foo)) { /*. . . */ } • Small, Fixed-Size Stack – Historically, the kernel stack is two pages. – Recently, the size of kernel stack is one page only!!!
Different Natures • No (Easy) Use of Floating Point – Supporting FPU is very expensive for kernel developers – Using floating point inside the kernel requires manually saving and restoring the floating point registers – It is very hard to use the technique called “lazy context switch” to speedup FPU context switching
Note: “DO” have some floating-point computations • Recompile GNU‘s libc with option “--withoutfp” to avoid using floating-point hardware while providing floating-point computations • Compile the module's. c files with gcc's – "-msoft-float" option and – "-D__NO_MATH_INLINES".
Different Natures • Synchronization and Concurrency – “Linux” is a preemptive multi-tasking “operating system. ” – The Linux kernel supports multiprocessing. • For example, Linux can use more than one core/processor to decode TCP/IP packets (named softirq) – Interrupts occur asynchronously – The “Linux kernel” is preemptive.
- Slides: 10