Home ” articles ” 2008 ” 02 ” 16.01.2008‣software

At a certain point in time, every system administrator (well, or most of them) has a question: “What would it be to come up with to do nothing, and it worked by itself?” Such a question arose for me during the application of the jack to a completely collapsed server. I wouldn’t be me if I was puzzled by this question exclusively myself, without puzzling anyone around. And one day it was decided to check a certain number of operating systems and choose the most convenient for installing the server. As a result, there was no general opinion. Someone decided to stay on Microsoft Windows 2003 Server, someone liked Linux more (there were three of them), and after carefully studying the results, I chose FreeBSD, which I use at the present moment and am not going to change to something else. Naturally, the question arises: “Why FreeBSD?” to which I will try to answer in this article.

What does it represent and how does it differ from the others? FreeBSD is a freely available, full-source, 4.4BSD-Lite version for computer systems based on Intel i386, i486, Pentium, Pentium Pro, Celeron, Pentium II, Pentium III, Pentium 4 (or compatible), Xeon, DEC Alpha and Sun UltraSPARC. It is mainly based on software from the CSRG group, U.C. Berkley, with some additions from NetBSD, OpenBSD, 386BSD and the Free Software Foundation (Well, how without it? And then somehow not in a friendly way – not to steal a port, a package or even a successful piece of code).

Among the announced advantages of FreeBSD is a complete upgrade of the virtual memory system with the integration of virtual memory and the buffer cache of the file system, which, according to the developers, “not only increases performance, but also reduces the amount of memory used by FreeBSD, making 5 MB configuration a more acceptable minimum.” To be honest, I will leave this statement on the conscience of the developers, since there was neither the time nor the desire to check FreeBSD 2.0. And besides, it was too lazy to look for a suitable iron.

Among the rest —full support for the NIS client and server, TCP transaction support, support for “dial-on-demand” in PPP, built-in DHCP support, improved SCSI subsystem, support for ISDN, ATM, FDDI, Fast and Gigabit Ethernet adapters (1000 Mbps), improved support for the latest Adaptec controllers and many thousands of bug fixes. Also, starting with FreeBSD 5, several new features are included, including those related to security. In order to improve the security of FreeBSD, the TrustedBSD project was formed, within the framework of which, among other things, an extensible MAC forced access control system, access lists ACLs for file systems and a new UFS2 file system were developed. Some TrustedBSD features have also been integrated into the NetBSD and OpenBSD operating systems. FreeBSD also supports file system encryption through the GDBE system, which was written by Paul-Henning Kamp, one of the leading developers. Other important features of FreeBSD relate to intra-core locks to improve performance on multiprocessor SMP systems and multithreading implemented by the KSE system, which is the default threading library since version 5.3.

And what, in fact, helps to do this within a single OS?

The FreeBSD kernel type refers to modular OS kernels. That is, unlike classic monolithic kernels (they provide a rich set of hardware abstractions; all parts of a monolithic kernel work in the same address space; used in traditional UNIX kernels such as BSD and Linux), which are now considered obsolete, modular kernels, as a rule, do not require a complete recompilation of the kernel when changing the composition of computer hardware. Instead, modular kernels provide one or another mechanism for loading kernel modules that support a particular hardware (for example, drivers). At the same time, the loading of modules can be either dynamic (performed on the fly, without restarting the OS, in a running system) or static (performed when the OS is rebooted after reconfiguring the system to load certain modules). All kernel modules work in the kernel address space and can use all the functions provided by the kernel. Therefore, modular cores continue to remain monolithic.

The modular core is a special programming interface (API) for linking modules to the core, to ensure dynamic loading and unloading of modules. In turn, not every program can be made a kernel module: certain restrictions are imposed on kernel modules in terms of the functions used (for example, they cannot use the functions of the standard C/C++ library and must use special analogues that are functions of the API core). In addition, kernel modules are required to export certain functions that the kernel needs for the correct connection and recognition of the module, for its correct initialization during loading and correct completion during unloading, for registering the module in the kernel module table and for accessing the services provided by the module from the kernel.

The possibility of dynamic loading of modules does not violate the solidity of the kernel architecture, since dynamically loaded modules are loaded into the kernel address space and then work as an integral part of the kernel. Among the advantages of this approach is the speed of work and unpretentiousness in the hard part. But there is also a rather significant disadvantage: the kernel works in the same address space and therefore the failure of one of its components can cause a global collapse of the entire system. No, it is, of course, kernel – so kernel, panic – so panic. But it’s still not pleasant enough.

If we compare the FreeBSD kernel with the architecture of the Linux kernel and the architecture of the Windows NT family kernel, the differences are significant in many ways. As for the much-loved Linux, here, like FreeBSD, we have a monolithic kernel with support for loadable modules. That is, the same kernel architecture as FreeBSD, the same pros and cons, but with a greater degree of modularity. It would seem wonderful, there is nothing to find fault with and means “Fuck this FreeBSD at all”, but there is a small catch here. FreeBSD is developed and released by a single development team, so the kernel exists in different versions only for different architectures (amd64, alpha, i386, pc98, Sparc64), but in general it remains unchanged. As for Linux, in this case, distribution developers support their own kernel versions (naturally based on the official version), which often makes the attached software for two Linux distributions from two different developers completely incompatible. A happy exception is Gentoo Linux, which allows you to run software compiled under any of the distributions (perhaps because it is a kind of hybrid of Linux and FreeBSD). Mandriva Linux, in turn, allows its users to compile third-party sources. Plus, all the FreeBSD modules undergo a very strict selection, which leads to more rare releases of new stable versions, but makes them more workable and “stress-resistant”.

Windows NT is built on a hybrid kernel. Although Windows NT is often called a micro-core operating system, this is not quite true. The NT microkernel is too large (more than 1 MB) to carry the “micro” prefix. The components of the Windows NT kernel are located in the displaced memory and interact with each other by sending messages, as it should be in micro-core operating systems. At the same time, all kernel components work in the same address space and actively use common data structures, which is typical of operating systems with a monolithic kernel. According to Microsoft experts, the reason is simple: a purely micro-core design is commercially unprofitable because it is inefficient. The disadvantages of this OS in relation to FreeBSD are just the same kernel size, the location of components in the displaced memory and their operation in a single address space. But there is an undoubted plus: where in NIX systems you have to do everything with your hands, you can do the same here using the built-in services.

The architecture and stability of the core components have been more or less sorted out. Although, only an axe will save you from the Congenital Syndrome of Crooked Hands and a “Smart” Head. Now let’s look at the usefulness of FreeBSD from the point of view of a system administrator and make an approximate comparison with the OS closest to it – Linux.