Installing Linux
◾
319
side (running applications) and the kernel side is handled through system calls. Through
the
system calls, running processes are able to communicate requests for process manage-
ment, memory management, I/O, and interprocess communication to the kernel.
Early operating systems used a monolithic kernel but one that was rather small because
computer memory was limited and operating systems of that era were not asked to do a lot.
As computer capabilities grew, operating systems became larger and monolithic kernels
became more and more complex.
A reaction to the complexity of the monolithic kernel was the development of the
micro-
kernel
, starting in the 1980s. In this approach, the operating system contains a smaller ker-
nel, which operates within privileged mode and in its own address space. To support the
expected range of functions, the operating system is extended by a number of subsystems
referred to as
servers
. Servers operate with user applications using
user mode and the user
section of memory’s address space.
Communication between application software and kernel is much like with the mono-
lithic kernel, but the kernel then calls upon servers to handle many of the operations. Thus,
the microkernel involves a far greater amount of system calls as the servers are separate
from the kernel.
Among the server components are file system servers, network servers, display serv-
ers, user interface servers, and servers that can directly communicate with device drivers.
Remaining in the kernel are the process scheduler, memory manager (including virtual
memory), and the interprocess communication between operating system components.
One of the most prominent operating systems to use the microkernel is Mach, Carnegie
Mellon University’s implementation of Unix.
The
hybrid
kernel compromises between the two extremes where the kernel is still kept
small, but server-like components are added on. Here, the server
components run in kernel
mode but often in the user’s address space. In this way, processes can call upon the serv-
ers more easily than with the microkernel approach and thus bypass some of the time-
consuming system calls. The small kernel might handle tasks such as interrupt handling
and process and thread scheduling. The servers, also called
modules
(as discussed shortly)
might handle virtual memory, interprocess communication, the user interface, I/O (device
drivers), and process management.
Windows NT, and later versions of Windows, including Windows 7 and 8
use forms
of hybrid kernels. The MacOS X and the iOS used on Apple mobile devices combine the
microkernel of Mach with components from FreeBSD and NetBSD (both descendants
from Berkeley Standard Distribution) that use a modular kernel and a monolithic ker-
nel, respectively. Thus, the resulting kernel, known as XNU (X is not Unix), is a hybrid
kernel.
You might wonder what the fuss is about. Those who work with either microkernels or
hybrid kernels cite that the monolithic kernel is too complicated and large. As the mono-
lithic kernel is essentially one large piece of code, making a minor modification to one
portion might have completely unexpected impacts on other portions. In fact, it is possible
that errors may arise that are very hard to identify and locate in the code. This could lead
to an unstable operating system that yields errors and system crashes for reasons that have
320
◾
Linux with
Operating System Concepts
little to do with the actual modified code. There are also concerns that the monolithic ker-
nel will be inefficient because of its size.
Imagine, for instance, that a programmer modifies a few lines of code that deal with an
interrupt handler. Unknowingly, the code change impacts some aspect of memory man-
agement. Now, a user is running a program and when virtual memory kicks in, the error
arises. The programmers cannot identify the cause because there is nothing wrong with the
memory manager. Tracing it to the changed interrupt-handling code may take a huge effort.
Linux was developed around a monolithic kernel. Andrew Tanenbaum, a computer sci-
entist
and author of many textbooks, initially criticized Linus Torvald’s Linux because he
felt that a monolithic kernel would not succeed with modern computers. This has led to a
continued debate over which approach is better.
Given the problems with a monolithic kernel, why would anyone want to produce one?
To improve on the efficiency and reduce the impact of errors of the monolithic kernel, the
modern monolithic kernel includes numerous
modules
, each of which implements one or
more of the core kernel’s responsibilities. Modules are loaded either at kernel initialization
time, or on demand. Thus, the kernel can itself be modularized. The efficiency of a mono-
lithic kernel’s execution is in part based on the number of modules loaded. Loading fewer
modules leads to a more efficiently executing kernel. Through modules, the Linux kernel
can be kept relatively small.
Figure 8.2 illustrates a rudimentary difference between the monolithic kernel and
microkernel. On the top, the monolithic kernel is large and handles all kernel operations.
System calls are limited to just the applications software invoking the kernel.
On the bot-
tom, the microkernel is smaller and simpler but system calls exist now between the kernel
and servers as well as between the application software and servers.
8.2.4 Loading and Removing Modules
As a system administrator, you are able to tune the kernel by adding and removing modules.
This is of course something you would only want to do if you find your Linux-operating
Running application
System calls
System calls
Servers
Device drivers
Device drivers
Running application
Kernel
Kernel
Hardware
Hardware
FIGURE 8.2
Monolithic kernel (top) versus microkernel (bottom).
Installing Linux
◾
321
system is not running efficiently leading you to remove modules or is alternatively lacking
functionality leading you to add modules. To see the modules that are loaded by default, use
the command
lsmod
. This will tell you the modules that are loaded, their size, and what
software or service might use that module. You can also inspect
each individual module
by using
modinfo
Do'stlaringiz bilan baham: