2.2. Kernel Organization

In this section, we view the organization of the 4.4BSD kernel in two ways:

  1. As a static body of software, categorized by the functionality offered by the modules that make up the kernel

  2. By its dynamic operation, categorized according to the services provided to users

The largest part of the kernel implements the system services that applications access through system calls. In 4.4BSD, this software has been organized according to the following:

Table 2.1. Machine-independent software in the 4.4BSD kernel
CategoryLines of codePercentage of kernel
total machine independent162,61780.4
headers9,3934.6
initialization1,1070.6
kernel facilities8,7934.4
generic interfaces4,7822.4
interprocess communication4,5402.2
terminal handling3,9111.9
virtual memory11,8135.8
vnode management7,9543.9
filesystem naming6,5503.2
fast filestore4,3652.2
log-structure filestore4,3372.1
memory-based filestore6450.3
cd9660 filesystem4,1772.1
miscellaneous filesystems (10)12,6956.3
network filesystem17,1998.5
network communication8,6304.3
internet protocols11,9845.9
ISO protocols23,92411.8
X.25 protocols10,6265.3
XNS protocols5,1922.6

Most of the software in these categories is machine independent and is portable across different hardware architectures.

The machine-dependent aspects of the kernel are isolated from the mainstream code. In particular, none of the machine-independent code contains conditional code for specific architecture. When an architecture-dependent action is needed, the machine-independent code calls an architecture-dependent function that is located in the machine-dependent code. The software that is machine dependent includes

Table 2.2. Machine-dependent software for the HP300 in the 4.4BSD kernel
CategoryLines of codePercentage of kernel
total machine dependent39,63419.6
machine dependent headers1,5620.8
device driver headers3,4951.7
device driver source17,5068.7
virtual memory3,0871.5
other machine dependent6,2873.1
routines in assembly language3,0141.5
HP/UX compatibility4,6832.3

Table 2.1, “Machine-independent software in the 4.4BSD kernel” summarizes the machine-independent software that constitutes the 4.4BSD kernel for the HP300. The numbers in column 2 are for lines of C source code, header files, and assembly language. Virtually all the software in the kernel is written in the C programming language; less than 2 percent is written in assembly language. As the statistics in Table 2.2, “Machine-dependent software for the HP300 in the 4.4BSD kernel” show, the machine-dependent software, excluding HP/UX and device support, accounts for a minuscule 6.9 percent of the kernel.

Only a small part of the kernel is devoted to initializing the system. This code is used when the system is bootstrapped into operation and is responsible for setting up the kernel hardware and software environment (see Chapter 14). Some operating systems (especially those with limited physical memory) discard or overlay the software that performs these functions after that software has been executed. The 4.4BSD kernel does not reclaim the memory used by the startup code because that memory space is barely 0.5 percent of the kernel resources used on a typical machine. Also, the startup code does not appear in one place in the kernel -- it is scattered throughout, and it usually appears in places logically associated with what is being initialized.

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <[email protected]>.
Send questions about this document to <[email protected]>.