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

Understanding of Unix philosophy

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Douglas McIlroy is the inventor of pipeline mechanism on Unix system and one of the founders of Unix culture. His philosophy of Unix is as follows:

The program should focus on only one goal and do it as well as possible. So that programs can work together. You should let the program handle the text data stream, because this is a general interface.

The more simplified version is: do one thing, do it well. Although only the third one is specific to Unix, Unix developers often emphasize these three tenets at the same time.

Rob Parker mentions the following motto in his Notes on Programming in C. Although these rules are about programming, it is not too much to be a Unix philosophy:

Rule number one: you never know where your program is going to waste time. Program bottlenecks often occur in unexpected places, so don't optimize your code until you're sure you've found it.

Rule 2: test the code. Optimize the speed of the program only if you have tested the code in detail and found that part of the code takes up most of the running time.

Rule 3: a fully functional algorithm (fancy algorithm) is inefficient in dealing with small-scale problems, because the constant in the time efficiency of the algorithm is very large, and the scale of the problem is often very small. Unless you know that you often encounter complex situations, make the code ugly but simple and efficient. (even if the problem is really large, try the second rule first. )

Rule 4: full-featured algorithms are easier to generate Bug than simple algorithms and more difficult to implement. Try to use simple algorithms and data structures.

Rule 5: data determines everything. If the selected data structure can manage the data well, the algorithm part is often self-evident. Remember, data structures, not algorithms, are the key to programming.

Rule six: there is no sixth rule.

The first and second rules of Pike reaffirm Gartner's famous maxim: "premature optimization is the root of all evil." [1] the third and fourth rules of Pike were restated by Ken Thompson: "exhaustion is best when doubts are uncertain." In fact, these two rules are also concrete manifestations of the KISS principle. Rule 5 is also mentioned in the previous Fred Brooks man-month myth. Jon Bentley's "Programming Pearls" also has a chapter on the same design philosophy. This rule is often reduced to "write code simply and use data wisely" as an example of "if your data structure is good, then the algorithm for controlling it is irrelevant." The sixth rule is, of course, Pike's humorous play on Monty Payson's sketch Bruces sketch.

In 1994, Mike Gancarz, a member of the X Window system development team, wrote "The UNIX Philosophy" based on his own Unix system experience and discussions with senior programmers using Unix systems in other fields.

One: small is beautiful.

Two: let the program do only one thing.

Three: create a prototype as early as possible.

Four: portability is more important than efficiency.

Five: the data should be saved as a text file.

Six: extract the full value of the software as much as possible.

Seven: use shell scripts to improve efficiency and portability.

Eight: avoid using user interfaces with low customizability.

Nine: all programs are filters for data.

In addition, there are ten principles that are not shared by everyone and are even the focus of debate (such as the dispute between the macro kernel and the micro kernel):

One: users should be allowed to customize the operating environment.

Second: make the operating system core small and light.

Three: use lowercase letters and be as short as possible.

Four: save paper and protect the woods.

Five: silence is golden.

Six: think in parallel.

Seven: the part plus part is greater than the whole.

Eight: the Pareto rule for finding problems.

Nine: programs grow with demand (Worse is better).

Ten: think at a level.

A Unix kernel-the core or key components of the operating system-includes many kernel subsystems such as process management, memory management, file management, device management, and network management.

Each subsystem has some functions:

Concurrency: because Unix is a multi-operating system, multiple programs run at the same time to improve system performance.

Virtual memory (VM): the memory management subsystem implements the concept of virtual memory so that users do not have to worry about the size of executable programs and the size of RAM.

Paging: it is a technique to minimize internal and external fragmentation in physical memory.

Virtual file system (VFS): VFS is a file system that helps users hide the complexity of different file systems. Users can use the same standard file system call to access different file systems.

The kernel provides interrupt and trap handling of these and other basic services, separation of user and system space, system calls, scheduling, timer and clock processing, and file descriptor management.

Some of the main functions of the Unix architecture concept are:

The Unix system uses an operating system kernel with centralized management policies and process activities.

All non-kernel software is organized into independent, core management processes.

Unix preemptive multitasking: you can run multiple processes at the same time, or in small time slices, any process can be interrupted and moved out to be executed by the kernel at almost the same time. This is called thread management.

Files are stored on a hierarchical file system disk, with a top-level location in the entire system (root, or "/"), files and directories, subdirectories, subdirectories, and so on.

With a few exceptions, the file system hierarchy within certain types of files or fake files for communication between devices and managed processes is visible. That's what it's called. Everything is a file. However, the state of Linus Torvalds, which is not accurate, can be better expressed as "everything is a byte stream". [1]

The UNIX operating system supports the following features and functions:

Multitasking and multiuser.

Programming interface.

Use files for abstract devices and other purposes.

Built-in networking. (TCP / IP is standard)

Persistent system service processes are called daemons and are managed by init or inetd.

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