Operating system study notes and personal opinions

operating system

Wangdao postgraduate operating system course notes and some personal opinions

Concept, function, goal

The most basic: bare metal (pure hardware) (need to learn the principles of computer composition)

Then: bare metal + operating system is our newly bought computer

Then: install the application

We all know this: What is an operating system?

Copy other people's words is:

1. Responsible for managing and coordinating computer resources such as hardware and software

2. Provide simple and easy-to-use services for upper-level applications and users (we think windows is kind)

3. The operating system is system software, not hardware

In the vernacular, most people can only use the operating system if you have installed it, you can play games and use the computer to surf the Internet. It’s a bit like if we want to develop Java, we need to have a JKD JRE environment.

Operating system definition

OS (Operating System, OS) refers to the control and management of the entire meter hardware and software resources of a computer system , and rational organization of dispatch computer work and the allocation of resources to be provided to facilitate users and other software interfaces and environment , It is the most basic system software in a computer system.

Functional goal

As a manager of system resources :

Processing, storage, file management, and equipment management are all its jobs

Do you first think that there is a function to schedule process work , how to open a process operating system?

The program needs to be placed in the memory before it can be processed by the CPU. He also has to distribute our equipment uniformly

As the interface between the user and the computer hardware :

Need to provide command interface (online command interface and offline command interface), program interface, GUI

So what is the online command interface ? ===>cmd this kind of interactive

What is the offline command interface ? ====>bat file is our batch command interface , there are a bunch of instructions

Program interface : such as C: \Windows \System32\user32**. dll** The programmer can call user32. dll in the program (the calling process is the
system call) to realize functions such as window creation. It can only be used indirectly through the user program.

Operating system characteristics

Four characteristics of operating system

Concurrency, sharing, virtual, asynchronous , concurrency, sharing are the most basic characteristics, the two are mutually existing conditions

Concurrent

Needless to say, let’s just put a PPT introduction

Concurrency : Refers to two or more events occurring in the same time interval . These events occurred at the same time on a macro level, but alternately occurred on a micro level.
Parallel : Two or more events happen at the same time at the same time.

The concurrency of the operating system refers to the existence of multiple running programs in the computer system at the same time.

A single-core processor (CPU) can only execute one program at a time, so the operating system is responsible for coordinating the alternate execution of multiple programs (the programs are executed alternately at the
micro level, but they look like they are executed at the same time at the macro level)

shared

Sharing is resource sharing, which means that the resources in the system can be used by multiple concurrently executing processes in the memory .

Divided into mutually exclusive sharing , simultaneous sharing , literally

Hey, does it smell like that? Have you seen this before? This sentence is very familiar. It seems that this is the difference between working memory and main memory. Main memory can be shared, but working memory can only be used by this process and instance.

What is the relationship between them?

If in the same time period, the two programs use memory, hard disk data, your product, and your product. If a certain condition is missing, they cannot be concurrent : then you share a fart, lack of sharing : how can the two send the same during the same time period file

virtual

Virtuality refers to the transformation of a physical entity into thousands of logical counterparts . The physical entity (the former) actually exists, while the logical
counterpart (the latter) is felt by the user.

This is an emmm product, it’s not good to give an example, just copy someone’s example

Background knowledge: A program needs to be put into memory and assigned a CPU to execute

If LOL needs 4GB of running memory, QQ needs 256MB of memory, Thunder needs 256MB of memory, and NetEase Cloud Music needs 256MB of memory... My computer: 4GB of memory.
Problem: These programs require much more than 4GB of memory to run at the same time , so why do they Can it run on my computer at the same time?

Use the " space division multiplexing technology " in virtual technology

In a computer with a single-core CPU , the user has opened the following software. …… LOL QQ Douyu.com Yiyun Music

Why can they be used at the same time?

In fact, only one single-core CPU works. How can it pretend to be 4 CPUs?

Time division multiplexing technology : microscopically, the processor alternately serves each process in each tiny time period

These technologies will be mentioned in detail later

If the computer cannot be concurrent, what else does the virtual technology do? Do you need him?

asynchronous

Do we often encounter asynchronous in development? Asynchronous request and asynchronous interaction. Is the asynchrony here the same as the asynchronous characteristics of our computer operating system?

I still copy a definition

Asynchrony means that in a multi-program environment , multiple programs are allowed to execute concurrently , but due to limited resources, the execution of the process is not consistent to the end, but stops and moves forward at an unpredictable speed. This is the process The asynchronous nature . emmm is different, it's a bit like blocking

OS development and classification

Copy the picture to see

Insert picture description here

Manual operation stage

No operating system, only machine code

Main disadvantages : users monopolize the entire machine, and the contradiction between human and machine speed leads to extremely low resource utilization

Single-pass batch processing system

Introduce offline input/output technology (completed with tape), and supervise the program responsible for controlling the input and output of the job

This supervisory program is the
main advantage of the prototype of the operating system : it eases a certain degree of contradiction between human and machine speed, and improves resource utilization.
Main disadvantages : Only one program can run in the memory, and the next program can be loaded only after the program has finished running. The CPU has a lot of time in idle waiting for I/0 to complete . Resource utilization is still very low.

Multi-pass batch processing system

That is, every time multiple programs are input to the memory, the operating system is officially born, and interrupt technology is introduced, and the operating system is responsible for managing
the operation of these programs . Concurrent execution of various programs

The main advantages : multi-channel programs concurrently , sharing of computer resources . Resource utilization has been greatly improved, CPU and other resources remain "busy"
, and system throughput has increased .

Main disadvantages : long user response time and no human-computer interaction function (after the user submits his own job, he can only wait for the computer to complete the processing, and
cannot control his own job execution in the middle)

Why can the Duotopi processing system greatly increase the utilization rate of resources? ?

Take the example in the video

Insert picture description here

Insert picture description here

Time-sharing operating system

The computer serves each user/job in turn in units of time slices , and each user can interact with the computer through the terminal.

Hey, this is not familiar to you. Is there a time slice rotation method for our thread work?

Main shortcomings : Can not give priority to some urgent tasks. The operating system is completely fair to each user/
job , cyclically serving a time slice for each user/ job, and does not distinguish the urgency of the task .

Real-time operating system

Main advantages : It can respond to some urgent tasks first, and some urgent tasks do not need time slices to queue up . Isn't it just being able to jump in the queue?

Under the control of the real-time operating system, the computer system processes the external signal in a timely manner after receiving the external signal, and must process the event within a strict time limit. The main characteristics of real-time operating systems are timeliness and reliability

Real-time operating systems are further divided into hard real-time systems (which must be processed within an absolutely strict stipulated time) and soft real-time systems (which can accept occasional violations of time regulations)

Other operating systems

Network operating system : It was born with the development of computer networks. It can organically combine computers in the network to realize data transmission and other functions , and realize the sharing of various resources in the network (such as file sharing) and the relationship between each computer. Inter-communication . (For example: Windows NT is
a typical network operating system, and the website server can be used)

Distributed operating system : The main feature is distribution and parallelism . Each computer in the system has the same status, and any work can be distributed on these computers, and they can complete this task in parallel and cooperatively.

Operating mechanism, system structure

Two instructions

Privileged instructions : such as memory clear instructions (users are not allowed to use)

Non-privileged instructions : such as ordinary arithmetic instructions

How does the CPU judge whether it can execute privileged instructions?

The state of the two processors

User mode : also known as head mode

Core state : also known as tube state

Use a certain flag in the program status word register (PSW) to identify what state the current processor is in. For example, 0 is the user mode, 1 is the core mode

Have we heard these two words there too?

Two procedures

Kernel program : The kernel program of the operating system is the administrator of the system. It can execute privileged instructions or non-privileged instructions and run in the core state.

Application : In order to ensure the safe operation of the system, ordinary applications can only execute non-privileged instructions and run in user mode.

Operating system kernel

The part of the operating system closest to the bottom layer is called the kernel

I copied a picture

Insert picture description here

The kernel can be divided into time management , interrupt processing , primitives (equipment driver, CPU switching, etc.)

Clock management : realize the timer function, what process switching we commonly use , and process scheduling based on clock management

Primitive : Primitive is a special program. It is the part closest to the hardware , and the operation of this kind of program is atomic . Short running time and frequent calls

Some operating systems do not classify these functions ( process management, memory management, device management, etc.) as "kernel functions." In other words, different operating systems may have different divisions of kernel functions

Architecture

I copied a picture

Insert picture description here

Big kernel : the main function modules of the operating system are regarded as the system kernel, running in the core state

Advantages : High performance
Disadvantages : The kernel code is huge, the structure is chaotic, and it is difficult to maintain

The microkernel only keeps the most basic functions in the kernel.
Advantages : less kernel functions, clear structure, easy to maintain
Disadvantages : need to switch frequently between core mode and user mode, low performance

Guess you like

Origin blog.csdn.net/qq_22155255/article/details/111998490