The above diagram provides a conceptual view of the Linux architecture. Like all conceptual views, it is not a perfect match to the full complexity of Linux. The key point is to understand that the Kernel Space (shown in blue) and User Space (shown in yellow) represent two distinct addresses spaces. The Kernel Space is a hardware protected address space. The User Space communicates to the address via System Calls, and the kernel responds using the buffer address provided in the system call. The hardware communicates to the Kernel Space using hardware interrupts.
The Linux kernel runs in the kernel space. In a sense, the kernel is a server that responds to hardware interrupt requests and system call requests. The Linux kernel provides the following services:
- The kernel supports all hardware drivers. A few drivers are compiled into the kernel, but most are loanded on demand. The kernel configuration determines the drivers compiled into the kernel, and drivers available for dynamic loading.
- The kernel manages memory allocation to all processes and buffers. During the boot process, the kernel allocates much of the available memory to buffers. As processes demand memory, the kernel releases unused buffer space. The kernel always keeps a reserve, and, if necessary, will terminate processes that hog too much memory. Killing a memory hog process is the last resort, and occurs only when swapping no longer solves the problem with available memory.
- The kernel manages all processes via a scheduler. The scheduler, itself, is configurable. Thus, a scheduler configuration for a desktop favors streaming of data to improve the performance of music and videos. The scheduler configuration for servers, optimizes performance for server processes.
- Using the Virtual File System (VFS) a generiic interface for all file systems, the file system drivers implement the code necessary to interface to each file system. Like device drivers, most file system drivers are loaded on demand.
- The kernel implements all the drivers necessary to support networking.
- File system security is part of the kernel, as are firewalls, and virus checking.
The actual workings of the kernel are far beyond the scope of this course. For those readers interested in more informaintion on how the kernel works check out the Interactive Map of the Kernel.
As the interface between User Space and Kernel Space, system calls have both a User Space and Kernel Space implementation as shown in the following diagram:
This absolute separation of Kernel Space from User Space insures address space integrity. While some operating systems have over a thousand system calls, Linux has less than 150. Instead of more systems calls, Linux uses devices such as pseudo file systems and virtual sockets to pass information from the kernel space to the address. None of these mechanisms bypass the basic system call interface.
All user accounts, including the root user, operate in User Space. The root user just has permissions not granted to other user accounts, but it is still just a user account. The Commands layer includes all the GNU commands, including the various shells available to Linux. The Application layer includes shell scripts and other applications, including the graphical versions of the applications. Applications can directly access the C library, or use GNU commands.
The graphical environment in reality is a series of layered applications, as follows:
- The X Window layer consists of those applications that define a graphical window.
- As its name implies, the Window Manager layer is the application that manages the window environment. Linux actually supports different window managers.
- Linux supports a number of different desktops (such as KDE, Gnome, XFCE, and LXDE). One of these desktops occupies the Desktop layer.
The diagram could be extended to additional layers for include virtualization. New technologies often just build on the layers below it.
Linux distributions package all the pieces to meet the needs of different users.