Lead Image © katisa, 123RF.com

Lead Image © katisa, 123RF.com

FreeBSD Version 10 released

News from BSD

Article from ADMIN 19/2014
By
The Unix-like FreeBSD is viewed as highly reliable and forms the underpinnings of both Mac OS X and the Sony PlayStation 4. Version 10 introduces new features and performance gains.

For 20 years, FreeBSD [1] has been an efficient, secure, and stable open source operating system. Now version 10 has been released with some innovations.

FreeBSD is part of the Unix family, although it is not called Unix for legal reasons. FreeBSD is one of several systems descending from the Berkeley Software Distribution (BSD) Unix system developed at the University of California Berkeley. Although the BSD license is a Free Software license, unlike the GPL, it does not provide a "copyleft" protection that forces developers to make their changes available to the community. For that reason, companies can mix BSD with proprietary code or even take the code out of open source, which is one reason why BSD formed the basis for Mac OS and other proprietary operating systems. Authorities and companies in the fields of technology and IT use FreeBSD as an internal developer and server platform.

FreeBSD upholds the traditional Linux virtues of security and reliability. As an example of the trust that corporations place in FreeBSD, Sony based its PlayStation 4 on FreeBSD 9. Likewise, Juniper relies on FreeBSD as a robust operating system for network routers, and Apple uses parts of FreeBSD for its Mac OS X operating system.

FreeBSD claims to be the most mature Unix-like operating system for x86 servers. In the 1990s, FreeBSD established itself as an operating system for all sizes of web and FTP servers with its speed, reliability, and often years of uptime. This tradition became a commitment and was rarely interrupted.

With multiprocessor and multicore systems asserting themselves in the server segment of the market, the FreeBSD development team had to respond. The FreeBSD 5 kernel published in 2004 was completely remodeled in a time-consuming process for symmetric multiprocessing. This radical redesign led to problems that were largely not remedied until version 7.

The next, not quite as radical, upheaval took place with the introduction of virtualization and ZFS on FreeBSD 8 in 2009. The filesystem developed by Sun Microsystems with integrated volume management is designed for very large volumes of data and high data security. The port to FreeBSD required some adjustments to the kernel, but it also contributed to further stability and security. In many ways, the new FreeBSD 10 is quite revolutionary.

GCC Has Had Its Day

FreeBSD 10 uses a new compiler to build the kernel sources and the associated tools: LLVM/Clang [2] [3]. The GCC project's move to the new GPL version 3 license prompted the developers to remove GCC from the FreeBSD base system. (See the box titled "Stallman on Clang.")

Stallman on Clang

Free Software pioneer (and GCC creator) Richard Stallman has expressed dismay about the growing popularity of LLVM. He writes in a recent post, "For GCC to be replaced by another technically superior compiler that defended freedom equally well would cause me some personal regret, but I would rejoice for the community's advance. The existence of LLVM is a terrible setback for our community precisely because it is not copylefted and can be used as the basis for non-free compilers – so that all contribution[s] to LLVM directly helps proprietary software as much as it helps us."

LLVM, originally an acronym for Low-Level Virtual Machine, not only contains a compiler but also a number of tools and libraries. Traditional compiler systems perform a number of optimizations by compiling the source code. Then, they link the compiled modules together, ignoring some optimization potentials arising in this area. The reason is that the linker only sees the individual modules and not the entire program.

LLVM resolves this problem by first creating virtual bytecode, as found in RISC instruction sets (Figure 1). This bytecode can be optimized again during the link process.

Figure 1: Structure of the LLVM suite.

As the name LLVM suggests, part of the framework's architecture is based on a virtual machine that virtualizes a processor: either a main processor (CPU) or a graphics processor (GPU). At run time, the virtual machine converts the internally generate intermediate language (LLVM Assembly Language) to that of the current system. Its efficiency also allows for just-in-time compilation. Additionally, LLVM allows a flexible back-end system and supports a variety of processor architectures.

As an LLVM suite front end, Clang parses the C or C++ code and converts it to LLVM Intermediate Representation (LLVM IR). The LLVM back end then generates efficient machine code. At this point, the virtual machine is not used, because LLVM (i.e., x86, PowerPC, IA64) takes its place as a compiler back end for the current architecture. In addition to C and C++, front ends exist for Fortran, Haskell, and Ruby, and others are in development.

Because of the structure of the LLVM/Clang system, compiling FreeBSD with make build kernel and make buildworld now takes about 20 percent longer. However, this extra time is well spent; Clang checks the kernel's and the tools' C code in more detail and has thus revealed some errors that GCC had not found.

This structure also has an effect on the ported software (ports) in the FreeBSD ports tree. Most programs can be compiled with no or just a few code corrections using LLVM/Clang. However, other ports require the old GCC compiler suite. To use this, you need to install GCC parallel to LLVM/Clang and use it exclusively for the ports. Unfortunately, until all ports will build in Clang, the port makefiles do need some TLC, as follows:

CC=gcc47
CXX=g++47
CPP=cpp47

Because the FreeBSD back end is only available for the amd64, arm, armv6, and i386 platforms right now, use of the compiler suite is limited to these architectures. The other target platforms continue to rely on a slightly older version of the GCC suite.

Kernel World

The replacement of the compiler suite is not the only change in the new version of FreeBSD; new features also have been added. For example, FreeBSD 10 has a tickless kernel [4]. A normal kernel, as used by FreeBSD versions up to and including 9.2, listened for events. Events trigger, for example, read and write operations on the disk. To handle this kind of interruption, the system stores the CPU state to continue working at the same place after processing the event.

This procedure also takes place even if there are no read or write operations in idle mode. However, backing up the CPU state costs computing power, and thus time, energy, and  – on laptops – battery power, even though this is unnecessary in idle mode. The new kernel fixes this vulnerability by not listening for events at fixed times but only when they occur.

The advantage of this method is important not only for laptop power savings but also means an increase in overall performance. However, on servers with a high load, the energy savings are not substantial, because many events and read and write operations will typically occur.

Graphics

On FreeBSD, traditionally the X Window System, Xorg, takes care of switching to graphics mode. Graphical user interfaces rely on it, whereas the graphics card usually works in text mode until they are launched. Mode setting occurs when an X server is started in user space using the startx command, for example, or by starting a login manager. Unfortunately, this mode change leads to ugly screen flicker as well as security issues.

In contrast, the newly introduced Kernel Mode Setting (KMS) switches the operating system kernel to graphics mode, thus eliminating the previous drawbacks. FreeBSD uses Linux code for the transition, following the move by the Xorg project to KMS; this means that Xorg graphics drivers only work with KMS.

After the introduction of KMS, FreeBSD now uses the xf86-video-ati driver for AMD graphics processors and thus supports chipsets by this manufacturer. The FreeBSD wiki page [5] has published a table listing AMD graphics cards that work with the new KMS driver.

On the downside, the suspend and resume feature, which is particularly important for laptops, does not currently work with KMS. If you still want to use KMS, you need to add the following to the /etc/make.conf configuration file,

WITH_NEW_XORG=YES

and then recompile Xorg.

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus