Chapter One: Introduction to the Operating System (Tang Xiaodan's Notes on the Operating System) Super complete and detailed! ! !

Chapter 1: Introduction to Operating Systems

An operating system is a set of programs that can effectively organize and manage computer hardware and software resources, reasonably schedule various jobs, and facilitate users' use .

1.1 Objectives and functions of the operating system

1.1.1 OS target

1. Convenience 2. Effectiveness 3. Scalability 4. Openness

1.1.2 The role of the operating system

  1. The OS acts as an interface between the user and the computer hardware system.
  2. The OS acts as a manager of computer system resources文件、处理机、存储器、I\0设备 .
  3. The OS implements the abstraction of computer resources

1.1.3 The main driving force to promote the operating system

  1. Continuously improve computer resource utilization
  2. user-friendly
  3. Continuous updating of devices
  4. The continuous evolution of computer architecture
  5. Constantly put forward new application requirements

1.2 The development process of the operating system

The development of OS is related to computer hardware technology and architecture.
The first generation (1946-1955): the era of electronic tubes
The second generation (1955-1965): The transistor era
The third generation (1965-1970): The era of small and medium-sized integrated circuits
The fourth generation (1970-present): Large-Scale and VLSI Era

1.2.1 Computing-grade systems without an operating system

​1. Manual operation

In the early operation mode, the programmer put the pre-punched paper tape (or card) into the paper tape input machine (or card input machine), and then started them to input the program and data on the paper tape (or card) into the computer , and then start the computer to run. Only when the program finishes running and the calculation results are taken away, the next user is allowed to go on the computer.

  • Disadvantages: 1. User monopolizes the system 2. CPU waits for manual operation

​2. Offline input\output mode

The programmer uses the perforated paper tape to input the data on the paper tape to the disk through the peripheral computer, and then transfers the data from the disk to the memory at high speed, and then outputs the output result to the corresponding output device through the peripheral computer.

This can solve the contradiction between man-machine and CPU and I/O device speed mismatch.

1.2.2 Single-channel batch processing system

​Processing process of single-

In order to realize the continuous processing of jobs, it is necessary to first input a batch of jobs to the tape offline, and configure a supervisory program (Monitor) in the system. Under its control, the batch of jobs can be processed one after another. Continuous processing.

  • Purpose: Improve utilization and throughput

  • Features: 1. Single channel 2. Sequential 3. Automatic

  • Cons: Resources are underutilized

1.2.3 Multi-batch processing system

​Basic concepts of multiprogramming

In a multiprogramming system, the jobs submitted by users are first placed on the external storage and arranged in a queue, called the backup queue .

Then, according to a certain algorithm, the job scheduler selects several jobs from the backup queue and loads them into the memory, so that they can share the CPU and various resources in the system .

  • Features: 1. Multi-channel 2. Disorder 3. Scheduling

  • Advantages: 1. High resource utilization rate 2. Large resource throughput

  • Disadvantages: 1. Long average turnaround time 2. No interactive capabilities

​Problems that need to be solved in multi-

  • processor contention problem

  • Memory Allocation and Protection Issues

  • I/O Device Allocation Issues

  • Document organization and management issues

  • job management issues

  • User-system interface issues

1.2.4 Time-sharing system

​Introduction of time-sharing

The generative doctrine of time-sharing system lies in the needs of users

  • User needs: human-computer interaction, shared host, easy for users to access the computer

​Key Issues in Time Sharing

The host assigns the CPU to each terminal in turn in a very short time slice until all jobs are run. If a job does not complete the calculation within the time slice allocated to it, the job will be suspended, and the processor will be used by other jobs to wait for the next round before continuing to use it. If the number of terminals is small, each terminal can quickly regain the CPU, so that each terminal can get a timely response.

  • (1) Receive and configure multi-channel cards and buffers in time
  • (2) Timely processing jobs are directly entered into the memory and adopt rotation operation mode.

​Characteristics of a time-sharing

1. Multiplex. Multiple terminals are allowed to be connected to one host, and the system serves each user according to the time-sharing principle;

2. Independence. Each user occupies a terminal and operates independently without interfering with each other;

3. Timeliness. The user's request can be responded in a very short time;

4. Interactivity. Users can conduct extensive man-machine dialogues with the system through the terminal.

  • Disadvantages: can't effectively handle urgent tasks OS is completely fair to each user/job, round-robin for each user/job

    Jobs serve a time slice and do not differentiate between the urgency of tasks.

1.2.5 Real-time system

The so-called "real-time" means "timely", and a real-time system means that the system can respond to external event requests in a timely (or instant) manner, complete the processing of the event within the specified time, and control all real-time tasks to run in a coordinated manner .

  • Application requirements: 1. Real-time control 2. Real-time information processing

  • Types of real-time systems: 1. Industrial (weapon) control system 2. Information query system 3. Multimedia system 4. Embedded system

    real-time task type

(1) Periodic real-time tasks and non-periodic real-time tasks

(2) Hard real-time tasks and soft real-time tasks

  • Hard real-time systems: processing must be completed within an absolutely strictly specified time.

  • Soft real-time systems: Occasional time violations are acceptable.

    Characteristics of a real-time system

  1. multiplex
  2. independence
  3. timeliness
  4. interactivity
  5. Reliability (real-time system is higher than time-based system)
  • Advantages: It can respond to some urgent tasks first, and some urgent tasks do not need time slice queuing.

1.2.6 Development of Microcomputer Operating System

​According to word length

word length: the number of bits of a binary number processed at the same time

  • 8 bit 16 bit 32 bit 64 bit

​According to the mode of operation

​1. Single-user single-task operating system: CP/M, MS-DOS

​2. Single-user multitasking operating system
  The meaning of single-user multitasking operating system is that only one user is allowed to be on the computer, but the user is allowed to divide the program into several tasks so that they can be executed in parallel, thereby effectively improving the performance of the system
Representative :Early WIN

​3. Multi-user multi-tasking operating system

Multiple users are allowed to use the same machine through their own terminals to share various resources in the host system, and each user program can be further divided into several tasks so that they can be executed concurrently, thereby further improving resource utilization. and system throughput.
  Most of the large, medium and minicomputers are configured with multi-user and multi-tasking operating systems, while on 32-bit microcomputers, many are configured with multi-user and multi-tasking operating systems, the most representative of which is UNIX OS.

1.3 The basic characteristics of the operating system

concurrent, shared, virtual, asynchronous

1.3.1 Concurrency

Parallel and concurrent

  • Parallel: Two or more events occur at the same time
  • Concurrency: Two or more events occur within the same time interval (macroscopically) and microscopically at a certain point in time but not at the same time

Concurrency is the main means to improve system resource utilization and increase system throughput Concurrent execution of single processor and concurrent/parallel execution of multiprocessor

import process

  • A process refers to a running activity of a program in a computer on a certain data set. Before threads are introduced, it is the basic unit for resource allocation and scheduling by the system.

​ The introduction of processes can achieve concurrent execution

1.3.2 Sharing

Resource sharing, also known as resource multiplexing, means that resources in the system can be shared by multiple concurrently executing processes in memory.

Mutually exclusive sharing

  • Critical resources: resources that only one process is allowed to access for a period of time

​ Example: Printers, System Forms

Simultaneous access method

There is another class of resources in the system that allow "simultaneous" access to them by multiple processes over a period of time. The so-called "simultaneous" here is in the macroscopic sense in the uniprocessor environment, but in the microscopic sense, these processes access the resource alternately.

​ Disks, shared code, shared libraries, etc.

1.3.3 Virtual

In os, the function of turning a physical entity into several logical counterparts through a certain technology is called virtual.

  • Time division multiplexing: virtual processor (multiprogramming) technology, virtual device technology

  • Space division multiplexing: multiple programs share memory and multiple files share disk to improve the utilization of storage space

1.3.4 Asynchronous

In a multiprogramming environment, the system allows multiple processes to execute concurrently. In a single-processor environment, since there is only one processor in the system, only one process is allowed to execute at a time, and the rest of the processes can only wait.

It can be seen that due to the limitation of resources and other factors, it is usually impossible to execute the process "in one go", but run in a "stop and go" manner.

1.4 Main functions of the operating system

1.4.1 Processor management function

  • Main functions: create and cancel processes, coordinate the operation of processes, realize information exchange between processes, and assign processors to processes according to a certain algorithm.
  1. process control
  2. process synchronization
  3. process communication
  4. scheduling

1.4.2 Memory management function

  • The main task is to provide a good environment for the operation of multi-programs, improve the utilization rate of the memory, facilitate the use of users, and expand the memory logically.
  1. memory allocation

  2. memory protection

  3. address mapping

  4. memory expansion

1.4.3 Device management function

  • Main task: to complete the IO request made by the user process, allocate the required I/O device for the user process, and complete the specified IO operation; improve the utilization rate of CPU and IO device, improve the IO speed, and facilitate the user to use the I/O device .
  1. buffer management
  2. equipment allocation
  3. equipment handling

1.4.4 File management function

  • Main task: manage user files and system files for the convenience of users and ensure the security of files.
  1. Management of file storage space
  2. directory management
  3. File read/write management and protection

1.4.5 The interface between the operating system and the user

user interface

(1) Online user interface

(2) Offline user interface

(3) Graphical user interface

program interface

The program interface is set for user programs to access system resources during execution, and is the only way for user programs to obtain operating system services.

1.4.6 New Features of Modern Operating Systems

system security

  • authentication technology
  • Cryptography
  • access control technology
  • anti virus technology

Network functions and services

  • Telecommunication

  • resource management

  • application interoperability

support multimedia

  • Admission control function.

  • Real-time scheduling.

  • storage of multimedia files

1.5 OS structure design

OS结构
传统结构OS
现代结构OS
无结构OS
模块化结构OS
分层次结构OS

1.5.1 Traditional operating system structure

1.5.1.1 Structureless Operating System

When developing the operating system in the early stage, designers only focused on the realization of functions and obtaining high efficiency, lacking consistent design ideas from beginning to end.

The OS at this time is a collection of a large number of processes, and each process can call other processes arbitrarily, which makes the interior of the OS complex and confusing, so this OS is unstructured.

1.5.1.2 Modular Structure OS

​Basic concepts of modular

This technology is a structured programming technology that appeared in the 1960s. This technology is based on the principles of "decomposition" and "modularization" to control the complexity of large software.

In order to make the OS have a clearer structure, the OS is carefully divided into several modules with certain independence and size according to their functions.

​Module independence

In the module-interface method, the key issues are the division of modules and the provision of interfaces between modules.

Note:

  •   在划分模块时不能将模块划分得太小或过大。
    
  •   划分模块时注意模块的独立性问题。
    

​Two criteria to measure

  • advantage:

    ​ (1) Improve the correctness, understandability and maintainability of OS design.

    (2) Enhance the adaptability of OS.

    (3) Speed ​​up the OS development process.

  • Disadvantages:
    (1) During OS design, it is difficult to specify the interfaces between modules to meet the actual needs of interfaces after the module design is completed.
    ​ (2) In the modular structure design, the design of each module goes hand in hand, and it is impossible to find a reliable decision sequence, resulting in the "disorder" of various decisions, which will make it difficult for programmers to achieve "every step in the design". Decisions" are based on solid foundations.

1.5.1.3 Hierarchical OS

​Basic concept of hierarchical

​ When using this method to build an OS, an OS has been divided into several layers, each layer is composed of several modules, and there is only one-way dependency between each layer.

  • advantage:

​ (1) It is easy to ensure the correctness of the system.

(2) Ease of expansion and maintenance.

  • Disadvantage: reduced efficiency

1.5.2 Microkernel OS structure

Microkernel: A stripped-down version of the kernel that provides the core functionality of an OS.

Micro-kernel OS features: a combination of various technical advantages.
Examples: Mach, Minix, Windows NT, Hongmeng OS

At present, the kernel architecture can be divided into: microkernel and macrokernel

  • macro kernel

The macro kernel generally implements all the main core components of the system in the kernel. It is conceivable that the components of the kernel designed in this way are highly correlated, which is often said to be highly coupled, which is not conducive to modular design.

The advantage is also obvious, that is, it is fast. All communication between components is completed in kernel mode, there is no switching between processes, and there is no switching from user mode to kernel mode.

Typical representatives are Linux operating system and UNIX system.

Basic concepts of microkernel OS
1. Always small enough kernel
2. Based on client\server mode
3. Apply the principle of "separation of mechanism and strategy"
4. Adopt object-oriented technology

​Basic functions of the microkernel

Now the principle of "separation of mechanism and strategy" is generally adopted, and the mechanism part and the part closely related to the hardware are put into the microkernel.

1) Process (thread) management

2) Low-level memory management

3) Interrupt and trap processing

​Advantages of microkernel

The microkernel OS structure is based on the modularization and hierarchical structure and adopts the client/server model and object-oriented programming technology.

​ (1) Improve the scalability of the system

(2) Enhanced system reliability

(3) Strong portability

(4) Provides support for distributed systems

(5) Incorporating object-oriented technology into the problems existing in the
microkernel

Compared with earlier operating systems, microkernel operating systems are less efficient.

​ Reason: When completing a customer's service request to the OS, it is necessary to use messages to achieve multiple interactions and multiple user/kernel mode and context switches.


  • Reference: Computer Operating System (Fourth Edition) (Tang Xiaodan)

Guess you like

Origin blog.csdn.net/woschengxuyuan/article/details/126678032