"Operating System" - the basic concept of the operating system

1. The concept of operating system

1.1 Classification of operating systems

UNIX is a very early operating system. Both Linux and MacOS are based on the operating system extended from UNIX, while Android is extended from Linux, and IOS is extended from MacOS.

Now most computers are installed with windows, windows currently has different versions, windows7, windows10, windows11, etc...

The DOS operating system (that is, the black frame command window in the above picture) is launched by Microsoft (the operating system before windows). At present, windows is compatible with the DOS operating system. We can enter DOS by using it in the windows system and then windows+rtyping cmdwindow command.

Both DOS and Windows are actually operating systems. And they are all developed by Microsoft. DOS is a single-tasking, single-user, CLI-based operating system, while Windows is a multi-tasking, multi-user, and GUI (graphical user interface)-based operating system.

1.2 Composition of computer system

  • user
  • application
  • operating system (OS)
  • hardware (bare metal)

The operating system is a bridge connecting software and hardware. The operating system can directly control the hardware. For users, the user can use the operating system through the software, and can also directly use the operating system to control the hardware.

  • The user directly uses the operating system case: switch computer sound, you must know that the sound is controlled by the computer audio, the operating system provides us with a graphical interface, we can directly operate the audio through the mouse or keyboard shortcuts.
  • Cases of users using software: the operating system provides the software with an interface to operate the hardware. Take the video player we usually use as an example. Generally, common video players can control the sound. In essence, it is provided by the calling operating system. volume interface to control.

1.3 What does the operating system do

The operating system (OS) is the first layer of software configured on the computer hardware. We call it 系统软件the software we usually use 应用软件. Application software is software specially compiled for a certain application purpose, such as WeChat, QQ ...they are all installed in the operating system.

The operating system mainly has the following functions:

  1. User Interface: The user interface is the part of the operating system that creates a platform for the user and other applications running on the operating system to communicate with each other. The operating system's user interface facilitates user control of other software and provides ease of use. User interfaces can be of 3 main types; command-controlled, menu-driven, and graphical user interfaces.
  2. Resource management: Devices connected to the computer system, such as memory, storage, I/O devices, etc., are called computer resources. The operating system controls these resources and is able to use available resources efficiently so that the system never runs out of its resources. The operating system not only controls these resources, but also detects failures of resources, checks status, and connects resources to each other.
  3. Task management: The task management program of any operating system accepts instructions, analyzes and processes them. Task management harnesses the power of a computer's processor and distributes it to various tasks, controlling interrupts.
  4. File management: The operating system manages files on the computer, such as creating, deleting, accessing, copying, moving, storing files, etc. It also manipulates data and programs, such as sending and receiving data, moving and storing data, etc.
  5. Utilities: The operating system provides various utilities for users and other programs, such as file defragmentation, data compression, data backup and recovery, antivirus utilities, and more.

2. Goals and functions of the operating system

2.1 Goals of the operating system

Take the Windows system as an example. The Windows operating system has been updated and iterated, so what is the goal of its version upgrade?

  1. Effectiveness: Improve system resource utilization and system throughput.
  2. Convenience: If there is no graphical interface operating system, allowing users to control the hardware through commands, the threshold for computer entry will be raised at once, so all fool-like operations should be used as much as possible.
  3. Scalability: The hardware of the computer has been developing rapidly. The original memory of 8g may now support 128g, but it is necessary to ensure that the operating system can adapt to the development of hardware devices.
  4. Openness: The speed of software development is extremely fast. It is necessary to lower the threshold of computer software development, that is, no matter what kind of people can develop software based on the operating system.

2.2 Functions of the operating system

Mainly divided into three categories:

As the manager of computer system resources, the OS mainly manages what resources?

The OS provides three types of interfaces:

  • Program interface: Provides some callable interfaces for the application program, mainly for the application program to control the hardware through the interface.
  • Command interface: doc command window
  • GUI: graphical operation

The operating system abstracts hardware resources, users can directly operate hardware resources through the command window and GUI in the operating system, and applications can operate hardware resources through system calls and commands. For the user, the implementation details are encapsulated.

We open a browser, enter baidu.com, and then the application software will access the hardware network card device through the system call in the operating system.

The hardware will perform network communication according to the input address. After the hardware visits, it will get the response and return the data to the operating system. The operating system will package and process the response after receiving the response and then return it to our browser application software. The browser finally displays it, so we can see it.

The system call of the operating system is imperceptible to the user, and it hides the details of the implementation. Generally, what we can think of is that I enter baidu.com, and then the browser returns the result to me.

Three, the characteristics of the operating system

The relationship between the four basic characteristics

  • The premise of virtualization, sharing, and asynchrony is the existence of concurrency.
  • The premise of concurrency is the existence of sharing.

3.1 Concurrency

If we use a single-core processor to perform multiple tasks at the same time, macroscopically, it is thought that he is running multiple tasks at once, but microscopically, they are not executed at the same time, but the processor completes different tasks at high speed during the processing process. Switching, the time interval may be very, very small, so that we do not notice it at all.

In the same way: it's like a person can finish brushing teeth, washing face, and washing dishes within half an hour. Then the concurrent transactions he supports for half an hour are 3. In fact, he did not perform the three things at the same time, because he could not separate himself. Just within half an hour.

How to prove that the CPU is executing serially?

Regarding the cpu, we can open the task manager through the windows system - "then there is a resource monitor at the bottom -" after opening, we can observe that the cpu is executing serially.

CPU and processor essentially refer to one thing, a CPU can have multiple cores, the core is the real physical core (chip hardware), and often the processor will use hyper-threading technology, which divides each core into two threads.

The thread technology is to provide two logical processors on the basis of a single core, and use special hardware instructions to simulate the two logical cores into two physical chips, so two physical cores are four threads, forming four logical processor.

Assume that core 2, logical processor 4, is able to 并行execute the number of threads, mainly depending on the logical processor, 4个逻辑处理器可以并行处理4个线程.

But it is no problem to process thousands of threads concurrently (the bottom layer is the time slice rotation mechanism RR time slice fast switching, and each thread can obtain the execution right if it has a time slice)

For example, my computer is still a relatively old laptop with dual-core 8G running memory. At that time, because the computer was stuck and a 16G memory stick was added, I found that the startup software was still stuck because the running memory was temporarily stored by the stored application software. The data, although the memory is enough, but the CPU can't keep up, and it's useless.

Generally, we can use the following simple method to distinguish the quality of the CPU:

  • The number of CPU cores (the number of people who work, the more work, the better of course)

  • The number of CPU threads (logical processors) is the same as how many hands a person has to work. Some CPUs have only one hand, and hyperthreading means that there are two hands, and the other hand is auxiliary. , 8 people are much more powerful than 4 people with 8 hands;

  • The core display of the CPU (the core display refers to the integration of the processor (CPU) and the graphics processing unit (GPU) on one chip). This is very important for computers without independent graphics cards. The frequency of the core display and The number of cores determines the working speed of the computer. The frequency of nuclear display mainly has two indicators:

    • Basic frequency (main frequency), the main frequency is the operating frequency of a CPU. For example, the main frequency of the i59400F processor is 2.9Ghz, whether it is single-core or multi-core, all cores work at 2.9Ghz.
    • Acceleration frequency (turbo frequency), turbo frequency is an acceleration technology of Intel, which means that when a running program is started, the processor will automatically accelerate to the appropriate frequency, and the original running speed will be increased by 10%~20% to ensure the program A technology that works smoothly.
  • Memory frequency, this generally has little effect on the CPU, but is very important to the core display (because the core display shares memory with the CPU);

Generally, when we buy a computer, for example, someone refers to the logical processor as the number of threads. The processor generally has the following parameters. If there is no independent graphics card, then we need to look at the base frequency and acceleration frequency of the processor. Of course the higher the better.

3.2 Sharing

There are two types of shared resources

  • Simultaneous access mode: For example, computer disks are typical to allow multiple applications to operate disks at the same time. If it is not allowed, it is okay, we will not be able to access the disk at the same time by multiple software and download resources to the disk at the same time.
  • There are also some resources that are mutually exclusive and shared: the so-called mutually exclusive sharing means that although resources are shared, they cannot be accessed at the same time. If they are accessed at the same time, they need to be queued according to priority.
    A printer is a typical case. If multiple applications call printing at the same time, he will store the content to be printed in the print queue, and then print one by one. The same is true for audio equipment. If you are watching TV and a phone call comes in suddenly, your TV sound will disappear at this time, and it will be directly switched to a phone call.

Note: Only when there is concurrency can there be sharing, and only when there is sharing can there be concurrency.

Is it concurrent or parallel for a man to date four girlfriends at the same time?

Answer: Of course it is concurrent, because the man is one person, he cannot be shared at the same time, he is just dating 4 people in different places, and then the man switches back and forth

Is simultaneous marriage concurrent or parallel?

Answer: It is also concurrent, the same as above. Men can be understood as processors, which cannot be shared.

3.3 virtual

There are two main implementations of virtual

  • Time-division multiplexing technology: Divide the time into more than half for the program to use. For example, a computer has only 8 processors, but it runs hundreds of applications. Logically, hundreds of applications are running at the same time, but actually 8 processors Do high-speed switching among different tasks. For example, if a task is executed for 2 milliseconds, it will immediately switch to another task regardless of whether it is finished.
  • Space division multiplexing technology: This disk is a typical case, which divides a fixed-size disk into multiple logical disks. The hardware is actually still a disk.

3.4 Asynchronous

Asynchronous: The multiprogramming environment allows multiple programs to execute concurrently, but due to limited resources, such as only one CPU, the execution of the process is not consistent to the end, but stops and starts, and it advances at an unpredictable speed.

Although multiple programs are running at the same time, essentially multiple tasks are being executed asynchronously, and each task is executed independently without interfering with each other.

For example, process A is occupying the CPU for calculation, and process B also wants to occupy the CPU for calculation at this time. Process B can only wait. After process A finishes calculation, process A accesses disk resources. Before the calculation is finished, the A process takes out resources from the disk. The A process finds that B is occupying the CPU at this time. At this time, the A process needs to wait, and then continue to the CPU for calculation after B finishes the calculation. Process execution proceeds at an unpredictable rate because each process occupies resources for a variable amount of time

Reference: "Horse Soldier Operating System Explanation" https://www.bilibili.com/video/BV1Ha411e7D4/

Guess you like

Origin blog.csdn.net/weixin_43888891/article/details/131500048