Attachment: I. Overview
The standard UNIX operating system is an interactive time-sharing system, which provides the foundation and environment to support the whole process of program development and can support 40 end users. UNIX system is made up of at & amp; T) was developed in 1969 ~ 1970 by two programmers of Bell Laboratories under the guidance of T). UNIX has been very popular since it came out. It runs on various machines with different processing capabilities, from high-end microcomputers to mainframes. At present, UNIX can run not only on DEC's PDP- 1 1 and VAX- 1 1, but also on IBM's 370 and 3300 series computers and Amdahi's, Data General's and Hp's series computers. In recent years, almost all 16-bit computers and 32-bit microcomputers are competing to transplant UNIX. This situation is extremely rare in the history of operating system development. With the popularity of UNIX, the writing system of C language has become a striking language and has been widely used.
UNIX system has achieved great success because of its internal reasons and objective factors. One of the objective conditions is that many operating systems have been successfully developed before the emergence of UNIX, including successful experiences and lessons of failure. The designers of UNIX made appropriate choices after careful consideration, which made UNIX stand on the shoulders of predecessors and achieved success (it took 200 man-years for MULTICS to reach its original goal, while only 2 man-years for UNIX); Secondly, because people needed a system with convenient use, good development environment and moderate scale, UNIX was just the right time; Thirdly, UNIX was developed on PDP- 1 1 series computers, which have been widely used in the world, creating conditions for the widespread deployment of UNIX. Of course, the key to the success of UNIX lies in its own performance and characteristics.
The main characteristics of UNIX are: short and pithy, simple and effective, easy to understand, expand and transplant.
The core program of UNIX consists of about 10000 lines of C language code and 1000 lines of assembly language code, which are divided into 44 files that can be compiled and assembled independently, and each file is divided into several processes. These documents can be divided into the following three categories:
⑴ Assembly language files: Only two files in the system are written in assembly language, including 33 assembly subroutines and parts directly related to machine hardware, such as interrupt handling and system startup. In order to improve efficiency, some commonly used basic programs are also written in assembly language.
⑵C language file: * * * has 28 files, including the main process of process management, which can be divided into 190 subprograms. Files can be compiled independently and executed after being assembled by an assembler.
⑶C language global variable file: * * *14, which contains important descriptions of the structure. This kind of file cannot be compiled independently, and must be compiled in C language file.
Second, the main characteristics of UNIX operating system
1. Exquisite kernel and rich practical layer.
UNIX system is structurally divided into kernel layer and utility layer. The core layer is small, but the practical layer is rich. The core layer includes process management, storage management, equipment management and file system. The core layer of UNIX is designed very concisely, and its main algorithms are carefully designed after repeated deliberation. Therefore, the core layer only needs to occupy a small storage space, and the memory can reside, thus ensuring the efficient work of the system.
The utility layer is a part that can be separated from the core layer. It appears as an out-of-core program and runs in the user environment. These out-of-core packages contain a wealth of language processors. UNIX supports compilers and interpreters of more than a dozen commonly used programming languages, such as C, APL, FORTRAN77, PASCAL, SNOBOL, COBOL, BASIC, ALGOL68 and their compilers. It also includes common utilities of other operating systems, such as editing programs, debugging programs, and utilities related to system status monitoring and file management. UNIX also has a set of powerful software tools that users can easily use to develop new software. These software tools include troff, a utility for processing text files, and SCC, a source code control program.
S (source code control system), command language Lexical analyzer and parser generators lex (music analyzer generator) and YACC(Ye).
Tanothercompiler) and so on. In addition, the UNIX command interpreter Shel.
L is also an extra-nuclear project. It is these out-of-core programs that provide users with a fairly complete programming environment.
The core layer of UNIX provides sufficient and powerful support for programs outside the core. Out-of-core programs are based on the kernel, and eventually they all use the underlying services provided by the kernel layer, and they gradually become a part of the "UNIX system". Core layer and practice layer are integrated to provide users with various good services.
2. Use a flexible command programming language shell
Shell is first and foremost a command language. More than 200 commands of UNIX correspond to 200 utilities. Shell is also a programming language. It has the control flow ability of many high-level languages, such as if, for, while, until, case statements, and the ability to assign values, replace, replace parameters and replace commands to string variables. Users can use these functions to write "Shell" programs in Shell language and save them in files. In the future, users only need to input the corresponding file name to execute it. This method is easy for system expansion.
3. Hierarchical file system
UNIX system adopts tree directory structure to organize all kinds of files and file directories. This organization is conducive to the allocation of auxiliary storage space and fast file search, and can also provide file sharing and access control capabilities for files of different users, ensuring safe and effective cooperation between users.
4. Unified handling of documents and equipment
Files in UNIX systems are unstructured byte sequences. By default, files are accessed sequentially, but if necessary, users can build their own structures for files, and users can also access files randomly by changing the read/write pointer.
UNIX treats peripheral devices like files, and peripheral devices are accessed, enjoyed and protected like ordinary files on a disk. Users don't have to distinguish between files and devices, nor do they need to know the physical characteristics of devices to access them. For example, the file name corresponding to the line printer in the system is //dev/lp. Users can output data from the printer by writing files. In this way, in front of users, the concept of the file is simple and easy to use.
5. Good portability
All UNIX utilities and 90% core codes are written in C language, which makes UNIX a portable operating system. The portability of the operating system brings the portability of the application program, so the user's application program can be used for minicomputers and other microcomputers or mainframes. Thereby greatly improving the working efficiency of users.
Although UNIX system has achieved great success, it is not without its shortcomings. To sum up, the criticisms of UNIX are as follows:
There are too many versions of 1. UNIX system, which makes the portability of application programs not fully realized.
UNIX is written in C language, so it is easy to modify and transplant. UNIX also encourages users to use UNIX tools to develop an environment suitable for their own needs, resulting in too many UNIX versions. In order to solve this problem, at present, AT&T has cooperated with four important microcomputer manufacturers (Inte
R, Motorola, Zilog and National Semiconductor) cooperate to develop a unified UNIX.
System V version, which will have a great impact on the standardization of UNIX.
2.UNIX system lacks the ability of real-time control, distributed processing and network processing.
This shortcoming is also constantly improving. UNIX-based distributed systems and real-time processing systems have been developed, and some have been successfully developed.
The core of 3.3. UNIX system is a disordered module structure.
90% of the core of UNIX system is written in C language, but its structure has no hierarchical structure, so it is very complicated and difficult to modify and expand.
These shortcomings of UNIX system are very small compared with its achievements, and its success is brilliant.
Third, the UNIX system structure
UNIX operating system adopts a module structure centered on global variables, so the system structure is more complicated, which is mainly manifested in circular calls between modules and global variables between files.
Structurally, UNIX can be divided into core layer and shell layer. The core layer is divided into the lowest device driver with hardware interface, physical storage block management, and the lower layer realizes storage management, file management, device management, process management and other functions. The outer layer of the kernel is the system call, which is the external interface of the UNIX kernel. The outermost layer is the interface between the user and UNIX system, and various other utilities and user programs also run at this layer.
The system structure is shown in Figure 8. 1.
1. shell
The user interface provided by UNIX is a command language called Shell, and the interpreter of this command language is also called Shell. When the system is initially started, a Shell process is established for each user, and each Shell process waits for the user to input commands. The simplest command form is the command line, which consists of the command name and several parameters separated by spaces. When Shell interprets and executes commands, it first distinguishes between command names and parameters, and then finds the corresponding file according to the command name, reads the file into memory, and interprets and executes it according to the given parameters.
The execution of the command is completed by fork system call and Shell process call.
After k, fork creates a child process of the Shell process and makes the Shell process wait. The subprocess interprets and executes the command. When the command is executed, the child process calls the exit system call to finish the work of terminating the child process and releasing the parent process. After the Shell process is released, a prompt will be given to allow the user to enter the next command line. The basic execution process of this command is shown in Figure 8.2.
UNIX interactive system requires users to wait for the execution of the previous line of commands, and then enter the next line of command after the terminal prompts. Because some commands take a long time to execute, in order to reduce the waiting time of users, users are allowed to write programs in Shell command language to represent the execution order of a group of commands in UNIX system. Programs written in command language are called Shell programs. The Shell program is stored in a file, and the command interpreter executes the commands in the Shell program when necessary.
2. System call
System call is the only way for a user program to request the operating system to serve it. In UNIX, system calls are called programmer interfaces. UNIX stipulates that user programs request system services with trap instructions, and interrupt trap programs in UNIX kernel turn to corresponding handlers according to trap types. The form of trap instruction is as follows:
UNIX version 6 * * * has 4 1 system calls, which can be divided into the following three categories:
① System calls related to process management, such as establishing subprocess, waiting for subprocess, sleeping, signaling, modifying data segment size, etc.
② System calls related to file management, such as creating files, connecting files, opening files, closing files, reading files, writing files, modifying current directories, modifying file attributes, etc.
③ Other system calls, such as taking the current user number, taking the calendar time, reading the running time of the process, changing the priority number, etc.
There are two ways to pass parameters in a system call. The first way: in the program, it is passed through the trap instruction successor unit. This way can be divided into direct way and indirect way. In direct mode, the following unit of trap instruction is allowed to put up to 5 parameters; In indirect mode, the subsequent unit of the trap instruction puts a pointer to the parameter area, which can store more parameters. The second method is to pass parameters through registers R0 and R 1.
UNIX system programmer interface, including a large number of library subroutines and title files. The title file defines the complex data structure used in the system call; Library subroutines and library functions provide additional program support for system calls.
3. Storage management
UNIX system was originally developed on PDP- 1 1. PDP- 1 1 is a segmented memory. In PDP- 1 1, a segment is called a page, and each page can contain several blocks, each block is 64 bytes, and the main memory is allocated in blocks.
Storage allocation adopts priority adaptive algorithm, and uses free area table to manage storage space. Each table has 50 entries, and each entry has 2 cells, one of which points to the starting block number of the corresponding free area, and the other indicates the size of the free area. The order of the items in the table is arranged from low to high according to the address of the free zone. If there are two adjacent free zones, they will be merged into one. The content of the table item is 0, indicating the footer.
Because PDP- 1 1 does not support virtual memory, the allocation and release of memory user area and disk swap area in UNIX are managed by storage management module. Under the management of the exchange program, the memory user area and the disk exchange area are integrated and play the role of virtual memory. Scan the PCB table for the exchange process, if there is a ready process in the auxiliary, check whether there is a free area in the memory, and if there is a free area, directly call in; Otherwise, some processes in memory should be swapped out. If there is no swappable process in memory, the swapped process will wait until some events occur and work again after waking up. When there are multiple ready processes in the auxiliary memory, they are switched to the memory according to the FIFO; When there are multiple processes in the memory that can be swapped out, the process with lower priority among the swappable processes is selected for swapping out.
When the process wants to increase the page length, it can do so by applying for a new page and releasing the old page. If there is not enough memory space, apply for a new page in the auxiliary memory and change the whole process to the auxiliary memory.
What is Linux?
199 1 year, LinusTorvalds, a student in Helexin, Finland, developed a Unix-like operating system running on the 80386 platform, named Linux for his own use and study. In order to make it convenient for everyone who needs it, LinusTorvalds turned it into "free" software.
With the rapid development of Internet, programmers all over the world have a brand-new and effective way of communication. Thanks also to the GNU project hosted by RichardStallman a few years ago. Linux became a complete operating system in a few years. Its energy is released and becomes very reliable, and new improvements are added every day.
In order to make Linux easy to use, Linux also has many distributions, which is actually a complete program combination. There are many different Linux distributions and their version numbers. To avoid confusion, let's explain some common terms first.
When we talk about Linux, we generally refer to "RealLinux", that is, the kernel, which is the "heart" of all UNIX operating systems. But linux itself cannot be a usable operating system. You also need many software packages, compilers, library files, Xwindow systems and so on. Because the combination methods are different, the user-oriented objects are different, which is why there are many different Linux distributions.
Features of Linux
Linux operating system has developed very rapidly in just a few years, which is inseparable from the good characteristics of Linux. Linux contains all the functions and features of Unix. Simply put, Linux has the following main features:
1. Open
Openness means that the system follows world standards, especially OSI international standards. All hardware and software developed according to international standards are compatible with each other and can be easily connected with each other.
2. Multi-user
Multi-user means that system resources can be owned and used by different users, that is, each user has specific permissions on his own resources (such as files and devices) and does not affect each other. Both Linux and Unix have the characteristics of multi-users.
3. Multitasking
Multitasking is the most important feature of modern computers. It means that a computer executes multiple programs at the same time, and each program runs independently. Linux system schedules each process and accesses the microprocessor equally. Because the processing speed of CPU is very fast, the started applications seem to run in parallel. In fact, there is only a short time delay between the processor executing a set of instructions in an application and Linux scheduling the microprocessor to run the program again, so the user does not feel it.
4. Good user interface
Linux provides users with two interfaces: user interface and system call. The traditional user interface of Linux is a text-based command-line interface, that is, shell, which can be used online or offline on a file. Shell has strong programming ability, and users can easily program with it, thus providing users with a more advanced means to expand system functions. Programmable Shell refers to the combination of multiple commands into a Shell program, which can run independently or simultaneously with other programs.
System call provides a programming interface for users. Users can directly use the system call command provided by the system when programming. The system provides low-level and efficient services for user programs through this interface. Linux also provides users with a graphical user interface. It uses mouse, menu, window, scroll bar and other facilities to present an intuitive, easy-to-operate and interactive friendly graphical interface for users.
5. Equipment independence
Device independence means that the operating system treats all external devices as files. As long as their drivers are installed, any user can manipulate and use these devices like files without knowing their specific forms of existence.
An operating system with device independence treats each peripheral device as an independent file, thus simplifying the work of adding new devices. When a new device needs to be added, the system administrator will add the necessary connections in the kernel. This connection (also called device driver) ensures that every time a device is called to provide services, the kernel handles them in the same way. When new and better peripherals are developed and delivered to users, the operation allows them to be accessed without restriction immediately after being connected to the kernel. The key to device independence lies in the adaptability of the kernel. Other operating systems only allow a certain number or types of external devices to connect. A device-independent operating system can accommodate any kind and any number of devices, because each device is accessed independently through its dedicated connection with the kernel.
Linux is a device-independent operating system, and its kernel has strong adaptability. As more programmers join Linux programming, more hardware devices will join various Linux kernels and distributions. In addition, because users can get the kernel source code of Linux for free, users can modify the kernel source code to adapt to the newly added external devices.
6. Rich network functions are provided.
A perfect internal network is a major feature of Linux. Linux is superior to other operating systems in communication and network functions. Other operating systems do not have the network connection ability closely integrated with the kernel, nor do they have the flexibility to build these network functions. Linux provides users with perfect and powerful network functions.
Supporting the Internet is one of its network functions. Linux provides a large number of software supporting the Internet for free. The Internet has been established and flourished in the field of Unix. It is quite convenient to use Linux in this respect, and users can communicate with other people in the world through the Internet.
File transfer is its second network function. Users can transfer internal information or files through some Linux commands.
Remote access is its third network function. Linux not only allows the transfer of files and programs, but also provides a window for system administrators and technicians to access other systems. Through this remote access function, technicians can effectively provide services for multiple systems, even if these systems are located far away.
7. Reliable system security
Linux has taken many security technical measures, including read-write access control, protected subsystem, audit trail, core authorization and so on. To provide necessary security for users in a multi-user network environment.
8. Good portability
Portability refers to the ability to transfer an operating system from one platform to another so that it can still run in its own way.
Linux is a portable operating system, which can run in any environment and any platform from microcomputer to mainframe. Portability provides a way for different computer platforms running Linux to communicate with any other machine accurately and effectively without adding special and expensive communication interfaces.
Why use Linux?
Linux is "free" and there are so many "free" softwares on it. Why not use it?
Windows is too unstable to stand. Change the platform.
I want to learn UNIX, but I don't have much money in my wallet. Let's start with Linux.
Want to learn the operating system, where is the open source OS? But it is also very positive and promising.
Parallel computing based on Linux is not only low cost, but also powerful and has great potential. The important thing is that it has source code.
If you want to be a hacker (a kind of cyberman, of course), Linux is certainly one of the best tools.
Linux has unlimited potential commercial value, good performance and good stability, so it is a wise choice to replace commercial operating system.
Oracle, Infomix, sysbase and IBM all support Linux, so it is good to use it as a database platform. Tired of buying licenses again and again (profiteers often set such traps), Linux follows the Public Copyright License (GPL) just to my liking.
Linux is so suitable for Internet/Intranet that it can be jointly developed through the network itself. Why not use Linux in the network age?
Using Linux can greatly reduce the total cost of ownership (TCO). There is a limit to the patience of waiting for the patch of commercial operating system, and I can't stand being led by the business all the time. Open source Linux can at least give users some control. Open source allows users to add or delete certain functions according to their own needs, and users can customize them. Well done!
Using open source Linux, you can also develop routers, embedded systems, network computers, personal digital assistants and so on. GNU is really a huge treasure house of knowledge, why not use it?
Advocate the spirit and dream of free software and contribute your strength!
References:
Cyberworld
I hope it works for you!