Hot search terms: 360 Security Guard Office365 360 browser WPS Office iQiyi Huawei Cloud Market Tencent Cloud Store
operating system Storage: 1158720KB Time: 2014-04-22
Software Introduction: Ubuntu is a freely distributed and open source Linux-based operating system designed for humans, humans who have no previous experience with Linux...
To understand the Linux system, you must have a certain understanding of its system architecture, including the kernel, shell, file system and applications. The kernel, shell, and file system together form the basic operating system structure that allows users to run programs, manage files, and use the system. The editor below will give you an explanation of the Linux system architecture. Friends who are interested may wish to learn more.
I will use the following figure as a basis to explain the architecture of Linux. (This figure refers to "Advanced Programming in Unix Environment")
The innermost layer is the hardware, and the outermost layer is the applications commonly used by users, such as the Firefox browser, evolution to check emails, a computational fluid model, etc. Hardware is the material basis, and applications provide services. But between the two, there is still some twists and turns.
Remember Linux booting. Linux first starts the kernel (kernel). The kernel is a computer program. This program directly manages the hardware, including CPU, memory space, hard disk interface, network interface, etc. All computer operations are passed to the hardware through the kernel.
In order to facilitate calling the kernel, Linux makes the functional interface of the kernel into a system call. System calls look like C functions. 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 to use the kernel. System call is the smallest functional unit of the operating system. Neither an operating system nor applications based on the operating system can achieve functions beyond system calls. A system call function is like a stroke of a Chinese character. Any Chinese character must be composed of basic strokes (dots, horizontal strokes, apostrophes, etc.). I can't make up the 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. The 2 in both commands indicates that we want to query in category 2 (system call category) (the specific categories can be seen through $man man).
The functionality provided by system calls is very basic, so it can be cumbersome to use. A simple operation of allocating memory space to a variable requires multiple system calls. Linux defines some library routines to combine system calls into some commonly used functions. The above operation of allocating memory can be defined as a library function (a function like malloc()). For another example, when reading a file, the system call requires us to set up the required buffer. I can use the read function from the Standard IO library. This read function is responsible for both setting up the buffer and using the read system call function. Using library functions has no efficiency advantage for the machine, but it frees the programmer from the details. Library functions are like radicals of Chinese characters, which are composed of strokes, but it is easier to use radicals to form characters, such as "铁". Of course, you can also call the system function directly without using the library function, just like the word "人" without the radical.
(Actually, for an operating system to be called a UNIX system, it must have some library functions, such as ISO C standard library, POSIX standard, etc.)
The shell is a special application. Many users refer to it as the command line. The shell is a command interpreter (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 represent redirection and | to represent pipeline. I also used the shell to explain the meaning of & or |. The Shell then uses the command kernel to implement specific redirections or pipelines through system tuning. Before there was a graphical interface, the shell served as the user's interface. When the user wanted to run certain applications, he entered commands through the shell to run the program. The shell is programmable and can execute text that conforms to shell syntax. Such text is called a shell script. As you can see in the architecture diagram, the shell communicates system calls down to various applications, and also has many small tools of its own that can be used. Shell scripts can implement complex functions in just a few lines.
A philosophy of UNIX is to let each program do a small function independently as much as possible. The shell acts as the "glue" between these small functions, allowing different programs to work together with a clear interface (text flow), thus enhancing the functionality of each program. This is one of the reasons why Linux veterans encourage novices to use shells more and less graphical interfaces.
(There are many kinds of shells, the most common one is bash, and there are also sh, csh, tcsh, and ksh. They appeared in different eras and support different functions.)
A terminal using the bash shell
A shell corresponds to a terminal. Once upon a time, a terminal was a hardware device used to take input and display output. Nowadays, due to the popularity of graphical interfaces, the terminal is often a graphical window like the picture above. You can enter or export text through this window. This text is passed directly to the shell for analysis, interpretation, and then execution.
Finally, we get to general applications. An application is a program that can
1. Directly call system functions
2. Call library functions
3. Run the shell script
These applications can be developed in multiple languages. The most common is C language.
Summarize
Linux uses the kernel to implement dialogue between software and hardware.
Through this interface called by the system, Linux separates the upper-layer application from the lower-layer kernel, hiding the underlying complexity and improving the portability of the upper-layer application.
Library functions create modular functionality using system calls,
Shell provides a user interface and allows us to write scripts using shell syntax to integrate programs.
The above is an introduction to the Linux system architecture summarized by the editor. As can be seen from the pictures in the article, the Linux system mainly consists of hardware, kernel, system calls, shell, and library functions. After reading this article, I believe you will have an understanding of Linux. Have a certain understanding of the system.
Google Chrome downloads graphic and text operation content of web videos
How to set the computer shutdown timer? -Tutorial on setting up computer shutdown schedule
How to turn off Huawei pure mode? - Tutorial on turning off Huawei pure mode
What do you think of the computer configuration? -Computer configuration view tutorial
What should I do if my Apple phone suddenly goes black and cannot be turned on? -Tutorial on Apple phone suddenly black screen and unable to open
Detailed steps for renaming shape layers in Image Factory
How to exit safe mode on Xiaomi? -How to exit safe mode in Xiaomi
How to use Xiaomi Mobile Assistant? -Xiaomi Mobile Assistant usage tutorial
How to force restart Xiaomi phone? -How to force restart your phone in Xiaomi
How to set the computer shutdown timer? -Tutorial on setting up computer shutdown schedule