(reprint) Diagram of the system architecture of Linux Systems

Source: Internet
Author: User

I thought of the basics, explaining the architecture of Linux (architecture). (This image is referenced in "Advanced Programming in Unix Environment")

The most internal layer is the hardware, the outermost is the user commonly used applications, such as the Firefox browser, Evolution view mail, a computational fluid model and so on. The hardware is the material foundation, and the application provides the service. But between the two, there will be some setbacks.

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

To facilitate the invocation of the kernel, Linux makes the functional interface of the kernel into a system call. The system call looks like a C-language function. You can call it directly in the program. The Linux system has more than 200 such system calls. Users do not need to understand the complex structure of the kernel, they can use the kernel. System calls are the minimum functional units of the operating system. An operating system, and operating system-based applications, are not capable of exceeding system invocation. A system call function is like a stroke of a Chinese character. Any Chinese character must be composed of basic strokes (dots, bars, apostrophes, etc.). I can't figment strokes.

Enter $man 2 syscalls on the command line to see all system calls. You can also view the description of the system call read () by $man 2 read. 2 of the two commands indicate that we want to query in Class 2 (System call Class) (what each class can see through $man man).

The functionality provided by system calls is very basic, so it is cumbersome to use. A simple operation that allocates memory space to a variable requires the use of multiple system calls. Linux defines some library functions (libraries routine) to combine system calls into some common functions. The above operations for allocating memory can be defined as a library function (such as malloc ()). For example, when reading a file, the system call asks us to set the desired buffer. 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. Using library functions is not an efficient advantage for machines, but it is possible to save programmers from the details. Library functions are like the radicals of a Chinese character, which consists of strokes, but the use of radicals makes it easier to compose words, such as "iron." Of course, you can also simply call the system function without using the library function, just like the word "human", without radicals.

(In fact, an operating system is called a UNIX system, you have to have some library functions, such as the ISO C standard library, POSIX standards, etc.). )

The shell is a special application. Many users call it the command line. The shell is a command interpreter (interpreter), and when we enter "Ls-l", it interprets this string as

1. Locate the file (/BIN/LS) in the default path,
2. Execute the file and attach the parameter "-L".

I previously used > to redirect, to use | To represent the pipeline, and also to explain & or | meaning through the shell. The shell then passes the system tune and uses the command core to implement specific redirects or pipelines. Before the graphical interface, the shell acts as the user's interface, and when the user wants to run certain apps, the shell enters commands to run the program. The shell is programmable, and it can execute text that conforms to the shell syntax. This text is called a shell script. You can see in the architecture diagram, the shell down-call system calls, up and down a variety of applications, while there are many of their own gadgets can be used. Shell scripts can implement complex functions in a few lines.

One of the philosophy 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 flow) to enhance the functionality of each program. This is one of the reasons that Linux veterans are encouraging novices to use the shell more, and less with a graphical interface.

(There are many kinds of shells, the most common being bash, plus sh, csh, tcsh, Ksh.) They appear in different eras, and the supported features vary. )


A terminal that uses bash shell

A shell corresponds to a terminal (terminal). Once, the terminal is a hardware device that is used to enter and display the output. Today, because of the popularity of the graphical interface, the terminal is often the same as a graphical window. You can enter or output text from this window. This text is passed directly to the shell for analysis and interpretation, and then executed.

Finally, we enter the general application. Application is a program that can

1. Call system functions directly
2. Call Library functions
3. Run the shell script

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

Summarize

Linux uses the kernel to implement hardware and software dialogs.

This interface, which is called by the system, separates the upper application from the lower layer, hides the underlying complexity, and improves the portability of the upper-level application.

The library function uses the system call to create a modular function,

The shell provides a user interface and allows us to use the shell's syntax to write scripts to integrate the program.

Reprinted from: http://www.jb51.net/LINUXjishu/214104.html

(reprint) Diagram of the system architecture of Linux Systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.