What is the Linux system architecture?

  

To understand the Linux system, it is necessary to have a certain understanding of its system architecture. The following small series will give you an explanation of the Linux system architecture. Interested friends may wish to understand.

I am based on the following diagram, illustrating the architecture of Linux (architecture). (Refer to FIG. "Advanced Programming in Unix Environment")

is a hardware innermost layer, the outermost layer is the common user applications, such as browsers firefox, Evolution view the message, a calculation of the fluid model and many more. Hardware is the material foundation, and applications provide services. But between the two, it still has to go through some twists and turns.

Remember Linux boot. Linux first starts the kernel. The kernel is a computer program that directly manages the management hardware, including the CPU, memory space, hard disk interface, network interface, and so on. All computer operations are passed to the hardware through the kernel.

In order to facilitate the call of the kernel, Linux makes the kernel's functional interface into a system call. The system call looks like a function of the C language. You can call it directly in the program. Linux systems have more than two hundred such system calls. Users do not need to understand the complex structure of the kernel, they can use the kernel. The system call is the smallest functional unit of the operating system. An operating system, as well as an operating system-based application, is unlikely to implement functions beyond system calls. A system call function is like a stroke of a Chinese character. Any Chinese character must consist of basic strokes (points, crosses, cymbals, etc.). I can't make strokes.

Enter $man 2 syscalls on the command line to see all system calls. You can also use $man 2 read to see a description of the system call read(). Two of these two commands indicate that we want to query in class 2 (system call class) (specifically what each class can be seen by $man man).

The functionality provided by the system call is very basic, so it is cumbersome to use. A simple operation to allocate memory space to a variable requires multiple system calls. Linux defines a library routine to combine system calls into some common functions. The above operation of allocating memory can be defined as a library function (a function like malloc()). For example, when reading a file, the system call asks us to set the required buffer. I can use the read function in the Standard IO library. This read function is responsible for both setting the buffer and for using the system call function that is read. Using library functions does not have an efficiency advantage for the machine, but it can save the programmer from the details. The library function is like the radical part of a Chinese character. It consists of strokes, but it is easier to form words using radicals, such as “iron”. Of course, you can also use the library function instead of the library function, just like the "people" word, without the radicals.

(Actually, an operating system must be called a UNIX system, you must have some library functions, such as the ISO C standard library, POSIX standard, etc.)

The shell is a special application. Many users call it the command line. The shell is a command interpreter. When we enter “ls -l”, it interprets this string as

1. Find the file in the default path (/bin/ls),

2. Execute the file with the parameter “-l”.

I used to indicate reorientation, with | Represents a pipe that is also interpreted by the shell & or | The meaning. The Shell then uses the command kernel to implement specific redirection or pipeline through the system tuning. Before the graphical interface, the shell acts as the user's interface. When the user wants to run some applications, the shell is used to enter the command to run the program. The shell is programmable and can execute text that conforms to the shell syntax. Such text is called a shell script. You can see in the architecture diagram that the shell can be used to access various applications, and there are many other gadgets that can be used. Shell scripts can implement complex functions in a few lines.

One of the philosophies of UNIX is to make each program as independent as possible to do a small function. The shell acts as a "glue" between these small functions, allowing different programs to work together in a clear interface (text stream) to enhance the functionality of each program. This is one of the reasons why Linux veterans encourage novices to use shells and use less graphical interfaces.

(shell there are many, the most common is the bash, in addition to sh, csh, tcsh, ksh. They appear in different years, supports functions are different.)

a Terminals using the bash shell

A shell corresponds to a terminal. Once used, a terminal is a hardware device that is used to input and display output. Today, due to the popularity of graphical interfaces, terminals are often like a graphical window. You can enter or output text through this window. This text is passed directly to the shell for analysis and interpretation, and then executed.

Finally, we enter the general application. The application is a program, it can be

1. Call the system function directly

2. Call the library function

3. Run the shell script

These applications can Developed in multiple languages. The most common is the C language.

Summary

Linux uses the kernel to implement software and hardware conversations.

Through this interface of the system call, Linux separates the upper application from the underlying kernel, hiding the underlying complexity and improving the portability of the upper application.

Library functions use system calls to create modular functionality,

Shell provides a user interface and allows us to script in the shell syntax to integrate programs.

The above is the introduction of the Linux system architecture. As can be seen from the pictures in the text, the Linux system is mainly composed of hardware, kernel, system call, shell, and library functions. I believe you through the reading of this article. Have a certain understanding of the Linux system.

Copyright © Windows knowledge All Rights Reserved