Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the architecture of Linux system?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how the Linux system architecture is, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

I illustrate the architecture of Linux (architecture) based on the following figure.

The innermost layer is the hardware, and the outermost layer is the user's commonly used applications, such as firefox browsers, evolution email checking, a computational fluid model, and so on. Hardware is the material basis, and applications provide services. But there are still some twists and turns between the two.

Remember when Linux started. Linux first starts the kernel (kernel), which is a computer program that directly manages the hardware, including 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 call the kernel conveniently, Linux makes the functional interface of the kernel into system call (system call). System calls look like functions in C language. You can call it directly in the program. The Linux system has more than two hundred such system calls. Users do not need to know the complex structure of the kernel to use the kernel. System call is the smallest functional unit of the operating system. It is impossible for an operating system and an operating system-based application to achieve functions beyond system calls. A system call function is like a stroke of Chinese characters. Any Chinese character should be made up of basic strokes (dot, horizontal, prime, etc.). I can't make up strokes.

Enter $man 2 syscalls on the command line to view all system calls. You can also view the description of the system call read () through $man 2 read. 2 in both commands indicates that we want to query in category 2 (system call classes) (you can see what each class is through $man man).

The functionality provided by the system call is very basic, so it is troublesome to use. A simple operation of allocating memory space to a variable requires multiple system calls. Linux defines some library functions (library routine) to combine system calls into some common functions. The above operation of allocating memory can be defined as a library function (such as malloc ()). For example, when reading a file, the system call requires us to set the buffer we need. I can use the read function in the Standard IO library. This read function is responsible for both setting the buffer and using the read system call function. There is no efficiency advantage for machines to use library functions, but programmers can be saved from the details. A library function is like a partial radical of a Chinese character. It consists of strokes, but it is easier to use a side radical to form a character, such as "iron". Of course, you can also call the system function directly without using the library function, just like the word "person" without the side radical.

In fact, for an operating system to be a UNIX system, it must have some library functions, such as ISO C standard library, POSIX standard, etc.)

Shell is a special application. Many users call it the command line. Shell is a command interpreter (interpreter) that, when we type "ls-l", interprets this string as

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

two。 Execute the file with the parameter "- l".

I used > for redirection and | for pipe, which is also explained by shell & or |. Shell then through the system call, using the command kernel, to achieve specific redirection or pipeline. Before there was no graphical interface, shell acted as the user's interface, entering commands through shell to run the program when the user wanted to run certain applications. Shell is programmable and can execute text that conforms to the shell syntax. Such text is called shell scripts (script). As you can see in the architecture diagram, shell opens system calls and various applications, as well as many of its own gadgets that can be used. Shell scripts can implement complex functions in just a few lines.

One of UNIX's philosophies is to make each program perform a small function as independently as possible. Shell acts as the "glue" between these small functions, allowing different programs to work together with a clear interface (text stream), thus enhancing the function of each program. This is one of the reasons why Linux veterans encourage beginners to use shell more and use less graphical interfaces.

There are also many kinds of shell, the most common of which is bash, as well as sh, csh, tcsh, ksh. They appear in different ages and support different functions.)

A terminal using bash shell

A shell corresponds to a terminal (terminal). Once upon a time, a terminal was a hardware device used to input and display output. Nowadays, due to the popularity of the graphical interface, the terminal is often a graphical window, just like the picture above. You can input or output text through this window. This text is passed directly to shell for analysis and interpretation, and then executed.

Finally, we get into the general application. An application is a program that can

1. Call the system function directly

two。 Call library function

3. Run the shell script

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

Thank you for reading this article carefully. I hope the article "what is the architecture of the Linux system" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report