KC7MM Wiki

Amateur Radio with KC7MM

User Tools

Site Tools


linuxusernet:inside_linux:linux_layer_cake

A Look Inside Linux series

A series of short topics on how Linux works and how to make it work the way you want it to, which I present during the weekly sessions of the Linux User Net. The target audience is Hams who are new to Linux and want to know more about it, as well as experienced Linux users who can learn more about their chosen operating system. These are my notes for the presentations. (Russ, KC7MM)

7. A modular system: the Linux layer cake

Overview of Linux modular architecture. Prelude to a detailed look at each layer, this is followed by Layer 1, the Linux kernel.

Introduction

Last week's Look inside Linux covered installing Linux on a computer. If you have done that, then you're ready to customize your Linux box for your particular use by installing and configuring software, customizing the UI, connecting to external devices, and more. In effect, you'll act as your own system administrator (“sysadm”).

In order to be able to take full advantage of the flexibility that Linux gives you, you need some knowledge of how a Linux system works. A good place to start is to develop a basic understanding of why you had to install Linux in the first place – why an operating system (OS) is needed.

To that end, we'll begin with a high-level look at the modular nature of an operating system such as Linux. In the coming weeks I'll explore modular “layer” at a level sufficient to let you find your way around your system as you set it up and work on it.

Background: what is an operating system?

Let's back up a step from our freshly-minted Linux box.

Suppose you have just built a brand new computer system from parts. The hardware is all installed, and it's been configured through the motherboard's built-in setup utility. What now?

You want to run application programs, such as wsjt or a logger, for you to use – that's why you built the thing. So, you turn on the power. It comes to life: lights blink, fans whir, some stuff appears on the monitor, and then…it stops. You see a message on the screen to the effect that no operating system was found. What's that about?

What you have at this point is a bunch of discrete hardware components, each with its own data interface, and each blissfully unaware of the others. What you lack is any means of controlling and coordinating them. An operating system is a program that provides just that.

Happily for us, the computer is itself aware of this need. It knows that, once it has completed its on-board boot process, it needs to locate and load an external operating system.

Also fortunate is that we can install Linux in such a way that it's available to be discovered and loaded when the system wakes up. That's what makes it possible for people such as us to make good use of a computer without having to be a computer scientist.

Interfaces

You'll hear me speak often of interfaces. That's because it is one of the most important concepts in the computer world.

Interfaces are employed to allow different programs to communicate with each other. The key thing they do is to hide whatever is behind the interface, so that one program needs only to know how to use another program's interface in order to communicate with it – that is, to exchange data.

The details of how an interface works and how programs can interact with it is referred to as its Application Programming Interface, or API. Programmers “write to the API” whenever they need to include a system in their applications.

An operating system can be thought of as a layered series of programs, each having a software interface at its upper and lower boundary. Each layer connects to the one below it via their interfaces, collectively providing the services that make up a modern general-purpose computer system. The bottom layer interfaces with the system's hardware, the top layer interfaces with applications and/or the user.

OS "layers"

Let's look at how OS components are layered together.

Modern operating systems have three general layers:

  • A kernel that connects to the system's hardware and makes it available to application programs that need to use it.
  • An application layer where the system user's application programs run.
  • An optional graphics layer that provides graphics capabilities for the user interface.

Kernel

We've seen that the last step of the computer boot process is to locate and load an operating system. What it actually expects to run is the OS's kernel.

The kernel is the bottom layer of the OS cake. It connects to the hardware interfaces provided by the motherboard, and makes them available, through generic interfaces, to other programs that need to access them.

This is where device drivers operate, where file systems are created, and where system memory and data flow are managed.

All operating systems have a kernel, or some functional equivalent.

Applications

The kernel is vital, but it doesn't do the whole job by itself. What's needed in addition is an environment in which application programs can be loaded and executed. That's what the application layer does.

Computer programs are written in plain text, which is then run through a compiler. The compiler translates it into machine language, which it stores in an executable file – that is, a file that can be run on the system.

To run the program, the system needs to know how to locate and open the file, and then send the instructions it contains to the CPU for execution. This normally is done within the context of a process.

Another thing the system needs to provide is a means of controlling it, and of letting users move data in and out. This is accomplished through a user interface (called a shell in Linux).

  • A text-based interface accessed through a terminal can be run at this level. In the early days of computing, the terminal would have been a teletype machine (TTY), connected via a serial line. On a modern system, it generally is a terminal emulator that uses keyboard input and a video screen output.
  • The terminal presents a command line interface (CLI).

Graphics

As computers have grown more powerful, they have gained the capability of running a graphical user interface (GUI). This is vastly more complex than a text-based interface, in that it requires a graphical video subsystem consisting of dedicated hardware and software.

We'll go into this subsystem in detail at a later date. For now, a brief outline of its components will suffice.

  • Hardware in the form of a dedicated graphics processing unit (GPU) with associated RAM.
  • At the kernel level, device driver software for the hardware.
  • For the user interface, software running at the application level to:
    • Control the flow of data to and from the video subsystem.
    • Create and manage visual images on the screen for the user to interact with (e.g., windows).
    • Respond to user input.

The implementation of the software elements of the graphics subsystem can vary widely by operating system. Linux and MS Windows, for example, take completely different approaches. (I'll talk more about this in future sessions.)

Conclusion

Computer operating systems are software systems that provide the context for running application programs and for user interaction with them.

They are made up of individual functional components that work together by communicating through interfaces.

In Linux, these components are implemented as a series of “layers”, each layer depending on services provided by the layer below, and in turn providing services to the layer above.

We'll explore this “Linux layer cake” in some detail over the coming weeks.

Return to series index

linuxusernet/inside_linux/linux_layer_cake.txt · Last modified: 2022/02/21 17:28 by KC7MM