1. The content of this article comes from courseware and student notes of famous universities (on campus, I often see someone buying notes at high prices)
2. The instructor does not provide references, so he can only express his gratitude to the author. If your work is referenced, you can reply to the document to supplement the reference.
3. I will not answer questions not related to the article, and the article content is also difficult. I am also difficult to answer your questions. If you find a bug, you can use the reply method to help me fix it.
4. Computer Operating System
Suitable for computer operating systems and postgraduate entrance exams
For more information about the navigation bar of this course, see the navigation bar at the bottom of the page.
§ 1. 1 Operating System Concept
§ 1. 2 Operating System history
§ 1. 3 basic types of Operating Systems
§ 1. 4 operating system functions
§ 1. 5 computer hardware Overview
§ 1. 6 Algorithm Description
§ 1. 7 views on Operating Systems
§ 1. 3 basic types of Operating Systems
The basic operating system types are as follows:
(1) Batch Processing Operating System)
(2) time-sharing Operating System)
(3) real time operating system)
(4) Personal Computer Operating
System)
(5) Network Operating System)
(6) Distributed Operating System (Distributed Operating System)
The main features of the batch processing system are:
The user uses the computer offline. After submitting a job, the user no longer deals with the computer until the result is obtained. Jobs can be submitted directly to the management operator of the computing center, or through a remote communication line. The submitted jobs are stored in the system as backup jobs.
(2) batch processing. The operator processes the Jobs submitted by the user in batches. The operating system or supervisor is responsible for automatic scheduling and execution of each batch of jobs.
(3) multiple programs run. According to the Scheduling Principle of multi-channel program design, multiple jobs are selected from a batch of backup jobs to be transferred to the memory and organized to run them to become multi-channel batch processing.
The advantage of the Multi-batch processing system is that the system resources are shared by multiple jobs, and the job is automatically scheduled to run among jobs. During the running process, the user does not intervene in his/her own jobs, which greatly improves the utilization rate of system resources and job throughput. The disadvantage is that it is non-interactive. Once you submit a job, you lose control over its operation. In addition, the job is batch processed and has a long turnover time, making it inconvenient for you to use it.
Do not confuse multiple program systems with multiple processing systems. Generally, multiple processing systems can be used to prepare multiple CPUs to execute multiple programs at the same time. Of course, multi-channel programming technology must be used to effectively use multiple processing systems. Otherwise, the multi-channel programming principles do not necessarily require the support of multiple processing systems. Compared with a single processing system, a multi-processing system increases hardware facilities, but gains benefits such as improving system throughput, reliability, computing capability, and parallel processing capability.
1.3.2 time-sharing system
A time-sharing system generally uses time slice rotation to enable a computer to serve multiple end users. Each user can ensure a fast enough response time and provide interactive session capabilities. It has the following features.
Interaction: First, you can perform dynamic operations on the program.
Control. Second, it is convenient for users to submit jobs on the machine. Third, the time-sharing system also
It facilitates cooperation between users.
(2) multi-user synchronization: multiple users can simultaneously connect to and share data on their own terminals.
CPU and other resources to make full use of the system's efficiency.
(3) Independence: In terms of objective effects, users do not feel that others are using the objective effects.
This computer is the same as an exclusive computer.
A time-sharing operating system is an online multi-user interactive operating system.
UNIX is the most popular multi-user time-sharing operating system.
1.3.3 Real-Time System
Real-time systems are developed with the application of computers in real-time control and real-time information processing.
Real-time systems provide real-time response and high reliability. The system must ensure that the analysis and processing of real-time information is faster than its entry into the system, and the system itself must be safe and reliable. Real-time systems are usually specific. Compared with the batch processing system and time-based system, the resource utilization rate of the real-time system may be lower.
To design a real-time operating system, consider the following factors:
(1) Real-time clock management (timing processing and latency processing ).
(2) continuous human-machine dialog, which is often necessary for real-time control.
(3) overload protection measures should be taken. For example, for short-term overload
Queuing in the buffer zone, waiting for scheduling; for sustained overload, some tasks may have to be rejected
Input; in the real-time control system, some tasks are processed in time, and some tasks are abandoned or reduced.
The Service frequency of some tasks.
(4) redundancy measures must be taken for high reliability and security. Dual-host system front and back-end work, including mandatory
Required confidentiality measures.
1.3.4 general operating system
The batch processing system, time-based system, and real-time system are three basic types of operating systems. On this basis, an operating system with multiple types of operating features is developed, which is called a general operating system. It can have both batch processing, time-sharing, real-time processing, and multiple processing functions, or more than two of them.
1.3.5 operating system on PC
The operating system on a personal computer is a single-user interactive single-user operating system. The online interaction function provided by the personal computer is similar to that provided by the general time-sharing system. Because it is dedicated to individual users, it is much easier to schedule the processing machine and protect the storage required by multiple users and time-sharing. However, due to the popularity of personal computers, it is increasingly urgent to provide more convenient and friendly user interfaces.
Multimedia technology has rapidly entered the micro-computer system, which requires the computer to have high-speed signal processing, large memory and external storage, broadband transmission of large data volumes, and other capabilities, can simultaneously process multiple real-time events. A real-time multi-task operating system with high-speed data processing capability is required.
Currently, Windows and Linux are the main operating systems used on personal computers.
1.3.6 Network Operating System
A computer network is a system that connects multiple computer systems physically dispersed with autonomous functions through communication facilities to achieve information exchange, resource sharing, interoperability, and collaborative processing.
It has the following features:
(1) A computer network is a group of interconnected computer systems.
(2) These computers are autonomous and each computer has its own operations.
Systems that work independently under the control of network protocols
Same job.
(3) system interconnection should be implemented through communication facilities (hardware and software.
(4) The system implements information exchange, resource sharing, and mutual communication through communication facilities
Operation and collaborative processing to meet various application requirements.
The development and development of network operating systems are based on the original computer operating systems. Developed according to various protocol standards of the network architecture, including network management, communication, resource sharing, system security, and a variety of network application services to meet the above requirements.
Due to the emergence and development of network computing, one of the main features of modern operating systems is the ability to access the Internet. Therefore, in addition to the early 1990s s, systems such as Novell's Netware are called network operating systems. people generally do not specify a network operating system as a network operating system.
1.3.7 Distributed Operating System
It seems that a distributed system is no different from a computer network system. A distributed system can also be defined to connect a physically Distributed Autonomous data processing system or computer system through a communication network to achieve information exchange, resource sharing, and collaborative tasks.
However, there are some obvious differences to consider:
The development of computer networks follows the protocol, and there is no standard protocol for various distributed systems. Of course, computer networks can also be considered as distributed systems.
(2) distributed systems require a unified operating system to ensure the uniformity of system operations.
(3) The distributed operating system is transparent to users. However, for a computer network
To use resources on another computer
Specify the computer.
(4) networks are the basis of distributed systems. The distributed system is not only a physical
The loose coupling system is also a logically tightly coupled system.
(5) the distributed system is still in the research stage. The computer network is already under
Domain is widely used.
The emergence of network computing trends and high-speed networks in 1990s has made distributed systems more and more realistic. In particular, the emergence of Sun's Java language and Java virtual machines and Java OS running on a variety of general operating systems has further accelerated this trend. In addition, the development of software component technology will accelerate the implementation of distributed operating systems.
§ 1. 4 operating system functions
The following describes the basic functions of the operating system in five aspects: resource management and user interface.
1.4.1 processor management
In the case of multiple programs or multiple users, to organize multiple jobs to run at the same time, it is necessary to solve problems such as assigning Scheduling Policies to the processors, allocating implementation and resource recycling. This is the processor management function. The operating system provides different job processing methods for different processor management policies, such as batch processing, time-based processing, and real-time processing. It becomes an operating system with different features.
1.4.2 Storage Management
The primary task of storage management is to allocate, protect, and expand the internal memory.
Memory allocation. How to allocate memory to ensure that the system and users
The storage areas of the program do not conflict with each other.
(2) storage protection. Ensure that one program does not intentionally or unintentionally damage another program during execution, and that the user program does not damage the system program.
(3) memory expansion. When the memory required by a user's job exceeds the memory capacity provided by the computer system, the internal memory and external memory are combined for management, A virtual memory with a larger capacity than the actual memory is provided.
1.4.3 device management
Channel, Controller, and input/output device allocation and management. The task of device management is to assign channels, controllers, and input/output devices to the program requesting input/output operations based on certain allocation policies, and start the device to complete the actual input/output operations. Virtual Technology and buffer technology are often used to maximize the parallel working capabilities of devices and hosts.
(2) device independence. There are many types of input and output devices, which are used in different ways. Device management should provide users with a good interface, without having to involve specific device features, so that users can use these devices conveniently and flexibly.
1.4.4 Information Management (File System Management)
The above three types of management are the management of computer hardware resources. Information Management (File System Management) is the management of system software resources. If the file cannot be properly managed, it may cause chaos or even damage. This is the problem to be solved when managing information files.
Information sharing, confidentiality and protection are also the solutions of the file system. If the system allows multiple users to work together, users should be allowed to share information files. However, such sharing should be controlled and there should be authorization and confidentiality mechanisms. There is also a certain protection mechanism to prevent unauthorized users from calling and modifying files. Even in unexpected circumstances, such as system failure and improper use of files, users can try to protect information from damages. That is to say, the system is safe and reliable.
1.4.5 user interface
The preceding four functions are the management of resources by the operating system. The Operating System also provides a friendly user interface. Generally, the operating system provides two interfaces to serve users.
A user interface is a program-level interface that provides a group of generalized commands (or system calls and program requests) for user programs and other system programs to call. When these programs require data transmission, file operations, or other resource requirements, apply to the operating system through these broad instructions, and the operating system will complete the application on behalf of the operating system.
Another interface is a job-level interface that provides a set of control operation commands (or job control languages, or shell command languages in UNIX) allows users to organize and control the running of their jobs. There are two types of job control methods: Offline Control and On-line control. The operating system provides Offline Control job language and on-line control job control language.
§ 1. 5 computer hardware Overview
As mentioned above, the operating system manages and controls all hardware and software resources in the computer system. At the same time, because the operating system is a system software running on the hardware, we must also understand the hardware environment where the operating system runs. This section briefly introduces the computer hardware system.
1.5.1 basic hardware elements of a computer
There are four basic hardware elements that constitute a computer: processor, memory, input/output control and bus, and external devices. The logical relationship between these basic elements is shown in Figure 1.6 (see the following page ).
The processor controls and executes computer commands. A computer can have multiple processors or a single processor. This book focuses on the operating system of a single processor. A single processor is also called a CPU. Memory is used to store data and programs. Memory can be divided into memory and external storage, as well as buffers and cache for temporary data and program storage.
The input and output controllers and buffers are mainly used to control and temporarily store data and programs exchanged between external devices and computer memory.
A wide range of external devices. They are the basic unit for obtaining and outputting data and programs, including digital devices and analog devices. However, analog devices must pass the mode/number conversion before entering analog signals into the computer, the digital signal output by a computer can be displayed or output on a simulated device only after the digital/modulo conversion.
Various devices in the computer system are connected to each other through the bus. A bus is a communication line connecting all components of a computer. The bus of the computer system is divided into single bus and multi-bus. A single bus is a bus structure in which processors, external devices, and storage devices are connected together, while a multi-bus is used to separate the CPU and memory of the system, external devices and external storage are also connected separately with other bus for management and data transmission bus structure. Obviously, different bus structures have different influences on the Design and Performance of the operating system.
1.5.2 main registers related to the Operating System
Registers are closely related to the operating system because they are temporary storage devices that exchange data faster and smaller than the memory in the processor and are more expensive. The storage function in the processor is classified into two types: User-programmable registers and control and status registers. Programmers of machine or assembly languages can operate user programmable registers to achieve higher execution efficiency. The control and status registers are used to control and operate the priority of the processor, the protection mode, or the call relationship when the user program is executed.
Generally, there is no strict distinction or restriction between user programmable registers and control and status registers. In different systems, the functions and functions of registers may be different.
Typical user programmable registers include:
1. Data Register
Programmers can use programs to assign a large number of functions to data registers. Generally, any machine instruction that operates on data is allowed to access the data register. However, according to hardware settings, these registers may only be allowed for floating-point operations or restricted by some other regulations.
2. Address Register
Address registers are generally used to store the address of a certain data or instruction in the memory, or to store the entry address of a certain segment of data and instruction, and to perform more complex address calculations. The following registers can be considered address registers:
(1) Address Identification Register;
(2) Various beginning address registers are used for memory management;
(3) Stack pointer;
(4) device address registers.
3. Condition code register
A condition code register is also called a flag register. The bit of the condition code register is set by the processor hardware.
Typical Control and status registers include the following:
4. program counter PC
The address of the instruction executed in the next cycle in the program counter.
5. instruction register IR
The instruction register contains instructions to be executed.
6. program status word psw
Each bit in the State Register of the program represents different States and information in the system. For example, whether the execution mode allows interruption.
7. Interrupt Field Protection Register
If the system allows different types of interruptions, a set of Interrupt field protection registers will be set up to save the on-site and link interruption recovery points of the interrupted program.
8. process call stack
The stack is used to store the call name, call parameters, and return address during the process call.
Registers are widely used in computer systems. They are directly and closely related to the operating system. The operating system designer can design the operating system only after fully understanding the functions and interfaces of various registers provided by the hardware manufacturer.
1.5.3 memory access speed
Hardware vendors provide different types of storage devices, including removable storage media, such as optical disks, disks and tapes, hard disks, disk cache memory, high-speed cache, and registers.
In general, the access speed of storage media with larger capacity will be slower, but the unit storage cost will be lower. For example, a CD and a disk. Conversely, the higher the access speed of the storage media, the higher the cost, such as registers. The relationship between the access speed of the storage device and the storage size is 1.7 (see the next page ).
In addition to the above registers and storage media, the hardware devices related to the operating system design include the interrupt mechanism and the control part of the input and output devices, such as the Channel and DMA devices.
1.5.4 command execution and interruption
The most basic function provided by a computer is to execute commands. Any application can be completed only by executing commands. The basic process of executing commands is divided into two steps: the process of reading commands from the memory by the processor and the process of execution. The read command is read according to the address specified by the program counter PC, and the executed command is the instruction in the instruction register IR. The read and execute processes of commands are called an execution cycle.
The execution of commands involves data transmission between the processor and memory, or data transmission between the processor and external devices. Command Execution also involves data processing, such as arithmetic operations or logical operations. In addition, the execution of commands can also be a control process for other commands. The execution of an instruction can be a combination of the preceding situations.
In addition, although the address counter specifies the address of the next accessed command during or after a command is executed, external devices or computers may send urgently needed data or other emergency processing signals. In this case, the processor needs to pause the program being executed and forward it to the corresponding emergency event. After the process is completed, it will return to the original site for further execution. This process is called an interruption.
Interruption brings many benefits to the operating system design. First, it makes it possible to process many emergencies in real time. Furthermore, interruption can increase the processing efficiency, interruption also simplifies the programming of the operating system.
When the system is interrupted, the processor receives the interrupt signal and thus cannot continue to execute the original program in the program counter. At this time, the processor will save the current execution site (that is, the value in each register) and call a new program to execute on the processing machine.
§ 1. 6 Algorithm Description
Many algorithms are involved in the operating system design and principle description. For the sake of simplicity, this book defines the following keywords to describe the relevant process in the algorithm.
Begin
End
The beginning and end of an algorithm.
Repeat
Operation
...
Until Condition
Indicates that the operation described is repeated when the condition is not met ".
While Condition
Do
Operation
...
Od
Indicates that an operation is performed when the condition is met ". The keywords "do" and "OD" respectively indicate the start and end of the "operation.
If condition
Then
Operation
Else
Operation
Fi
When the conditions referred to by "if" are met, the related "operations" after "then" are performed; otherwise, the related operations after "else" are completed. The keyword "fi" indicates the end of condition judgment.
For example, the command execution cycle shown in Figure 1.8 can be described:
Repeat IR limit M [PC];
PC worker PC + 1;
Execute [ir];
Until CPU halt;
M [PC] indicates the instruction content in the memory unit shown in the PC.
Another example is:
Replace P [1: N] With an integer ranging from 1 to n (n> 1,
Set I = 1, 2, 3, 4, 5, 6, 7;
P [I] =, 6;
Describes the circuit replacement algorithm of P [I. (Circuit replacement refers to the replacement of K = P [... P [k]...] When k is [1: N .)
Solution: Begin
Local X, K;
K limit 1;
While k <= 7 do
X ← K;
Repeat print (X );
X → P [x];
Until x = K;
K Bytes k + 1;
Od
End
§ 1. 7 views on Operating Systems
In the previous sections, we discussed the basic concepts of several operating systems, the history of operating system development, the classification and functions of operating systems, and the hardware basics that operating systems depend on, the operating system is a manager that effectively uses computer resources and provides friendly interfaces for users. This actually represents a point of view on operating systems.
In this section, we will briefly discuss the different points of view in the study of operating systems. These points are not in conflict with each other, but represent a different view of the same thing (operating system. Each view helps to understand, analyze, and design the operating system.
1.7.1 the operating system is the manager of computer resources
It has been pointed out that the operating system is a collection of programs used to manage and control the hardware and software resources of the computer system. Therefore, it provides functions such as processor management, storage management, device management, and information file management. The management of each type of resource can be discussed in terms of resource record, resource allocation policy, resource allocation and Resource Recycling.
1.7.2 User Interface views
Users are not very interested in the internal structure of the operating system. They are most concerned about how to use the services provided by the operating system to effectively use computers. Therefore, what kind of user interface is provided by the operating system becomes a key issue, namely the two interfaces at the program level and job level proposed in the preceding section.
1.7.3 Process Management Perspective
Operating System calling the current program running is a dynamic process, especially the concurrency is an important feature of modern operating systems. Concurrency refers to the process segment in which the operating system controls many concurrent executions. Concurrent programs may be executed in parallel in a multi-processor system, but in a single processor, they are executed in a macroscopic parallel and microscopic order. They can run independently or indirectly or directly in a way that is mutually dependent and restricted. Concurrent segments are not only restricted by the activities of other segments, but also by the distribution of system resources. A program segment may be running or waiting for some resources or information being suspended. Therefore, the concept of "Operating System is a resource management program" cannot reveal their activities and status changes in the system, thus introducing the concept of "process. The so-called "process" refers to the execution of concurrent programs.
From the process point of view, studying the operating system is to discuss the operating system around the process running process, that is, the execution process of concurrent programs, then we can clearly discuss the process of these resource management programs carrying out activities in the system, and gain more understanding of the operating system functions.