Operating System Chapter 1 - Section 2: Characteristics of Operating System

operating system characteristics

image-20220303090311937

concurrency

Airborne King

Concurrency: Refers to two or more events occurring within the same time interval . These events occur simultaneously macroscopically, but alternately occur microscopically.

​ Often consider the confusing concept- parallel: refers to two or more events happening at the same time at the same time .

The difference between parallel and concurrent:

Parallel: perform two tasks at the same time (like you are chatting and watching movies while memorizing words);

Concurrency: From a macro perspective, the program is performing two tasks at the same time during the entire program running cycle . From a microscopic point of view, at a certain moment , the program is performing at most one task.

  • Example: Assume that the little slag and the old slag each have two girlfriends. Task 1: Date Number One; Task 2: Date Number Two…

    Parallel is two dating at the same time;

    Concurrency is to start the appointment task of number 2 at the same time after the appointment of number 1 is completed .

image-20220303124828018

operating system concurrency

Airborne King

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 will be responsible for coordinating the alternate execution of multiple programs, which is the concurrent execution just mentioned. (These programs are executed alternately microscopically, but macroscopically it looks like they are executed simultaneously)

Today's computers are generally multi-core CPUs. For example, Intel's eighth-generation i3 processor is a 4-core CPU. Although this means that 4 programs can be executed in parallel at the same time, the concurrency of the operating system is still essential. Contemporary people use computers with more than 4 programs that need to work at the same time.

In fact, the operating system appeared with "multiprogramming technology". Thus, operating systems and program concurrency were born together .

shared

Airborne King

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

image-20220303132127016

Sharing (resource sharing) is divided into two ways: mutual exclusive sharing and simultaneous sharing

  • Mutually exclusive sharing mode : Although some resources in the system can be provided to multiple processes, only one process is allowed to access the resource within a period of time;

    Example:

    ​ Mutually exclusive sharing method: use QQ and WeChat video. The camera can only be assigned to one of the processes at the same time. Most physical devices in a computer system, as well as stack space, variables, and tables used in some software, are critical resources that can only be used by one process.

    understand:

    ​ Mutual exclusion sharing means that when a resource is occupied by a process A, other process B who wants to use the resource can only wait. Only after the process A finishes using the resource, the process B can use the resource. This sharing method It is called mutually exclusive sharing, and this kind of resource is called critical resource or exclusive resource. Such as printers are critical resources.

  • Simultaneous sharing : Certain resources in the system allow multiple processes to access them "simultaneously" within a period of time .

    Example:

    ​ Simultaneous sharing method: use QQ to send file A, and use WeChat to send file B at the same time. From a macro perspective, both sides are reading and sending files at the same time, indicating that both processes are accessing hard disk resources and reading data from them. From a microscopic point of view, the two processes access the hard disk alternately.

    The so-called "simultaneous" often refers to simultaneous access on a macro level, while on a micro level, these processes may access the resource alternately (that is, time-sharing) . But sometimes it is also accessing and running at the same time on a micro level. For example, when you are playing a game and music is playing in the background, you will find that the game sound and music are emitted at the same time, which means that these two processes are using the speaker device at the same time. , the specific needs to be combined with reality.

The relationship between concurrency and sharing

Airborne King

Concurrency : There are multiple running programs in a computer system at the same time.
Sharing : The resources in the system can be shared by multiple concurrently executing processes in memory.

Look at the relationship between concurrency and sharing through the above example:

Use QQ to send file A, and use WeChat to send file B

  • Two processes are executing concurrently (concurrency);

    If concurrency is lost, there is only one program running in the system , and sharing loses its existence.

  • Need to share access to hard disk resources (shared);

    If the sharing is lost, QQ and WeChat cannot access hard disk resources at the same time , and cannot send files at the same time, so they cannot be concurrent.

To sum up, concurrency and sharing are conditions for the existence of each other.

image-20220303133318391

virtual

Airborne King

Virtual refers to changing a physical entity into several logical counterparts . The physical entity (the former) is what actually exists, while the logical counterpart (the latter) is what the user feels.

Understanding: the sharing and concurrency mechanism of memory resources;

image-20220303134029222

Time Division Multiplexing

The time-division multiplexing technology is the time-sharing technology, which can be used to implement virtual processors, virtual devices, etc., to improve resource utilization.

Time division multiplexing technology is divided into two technologies: virtual processor technology and virtual device technology

  • Virtual processor technology: Virtual processor technology uses multi-programming technology to create a process for each program, so multiple programs can be executed concurrently, so as to achieve time-sharing use of a computer, which can serve multiple users at the same time. Service, so that each end user thinks that there is a processor dedicated to him. Microscopically, the processor alternately serves each process in each tiny time period.
    • For example: a computer with a single-core CPU opens 6 software at the same time. On the surface, the user seems to have 6 CPUs serving himself at the same time, but in fact only one CPU is working.
  • Virtual device technology: through virtual device technology, a physical I/O device can be virtualized as a polymorphic logical I/O device, and users are allowed to occupy a logical I/O device, which allows a period of time A device accessed by one user becomes a shared device that allows simultaneous access by multiple users for a period of time .
    • For example: the printer in the office supports multiple computers to connect and operate at the same time.

Space Division Multiplexing Technology

The space division multiplexing technology refers to a way to achieve multiplexing by using space division. The space division multiplexing technology can be used to implement operations such as virtual disks and virtual storage, so as to improve resource utilization.

At the same time, space division multiplexing technology is divided into two technologies: virtual disk technology and virtual memory technology

  • Virtual disk technology: One hard disk can be virtualized into multiple virtual disks through virtual disk technology, which is safe and convenient to use.
    • For example: Dividing a hard disk into logical disks such as C, D, E, and F is virtual disk technology.
  • Virtual memory technology: use the free space of the memory to store programs and improve memory utilization. It is also possible to logically expand the memory capacity through virtual memory technology (essentially time-division multiplexing technology), which allows a program to run in a memory space far smaller than it through time-division multiplexing technology .
    • For example: a computer has only 4G memory, and if GTA5 - 4G storage consumption, QQ - 256MB storage consumption, WeChat - 256MB storage consumption are running at the same time, the system actually uses virtual storage technology (virtual memory) time-sharing Load and run the program, transfer only a part of the user program into the memory for running each time, swap out this part after the operation is completed, and swap the other part of the program into the memory. Through this replacement function, the user program is realized. Each part enters the memory to run in time-sharing. On the surface, the system only has 4G memory space, but in fact it seems to be much larger than 4G memory.

This content will be explained later.

summary

Through the above examples, we talked about the virtual memory and virtual device technology that can allow devices and processes to run concurrently in the same period of time in the time multiplexing technology, and the division of disk space and the sharing of memory resources in the space division multiplexing technology. Virtual disk technology and virtual memory technology. They all have a feature that allows hardware devices and processes to execute more efficiently and concurrently.

Obviously, if the operating system loses concurrency, only one program needs to run in the system within a period of time, and then the meaning of realizing virtuality will be lost. Therefore, without concurrency, there is no virtuality

asynchronous

Airborne King

Asynchrony means that in a multi-programming 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 starts, moving forward at an unpredictable speed. This is the process asynchrony.

  • Example: Let’s use the above example of the old scumbag dating two girls concurrently .

    The two girls each have the following commands:

    • No. 1's order 1: The old scum accompany me to eat

    • Order No. 1 2: The old scum give me your heart

    • Number two's order 1: Old scum, give me your heart

    • Number two's order 2: The old scum accompany me to eat

    The old scumbag has only one heart, so he can make an appointment like this:

    • 8:00 ~ 9:00 - have dinner with number one;
    • 9:00 ~ 10:00 - Give your heart to No. 1; ❤ At this time, No. 1 occupies the heart of the old scum, and the thread is blocked during the occupation. After returning this resource, the heart of the old scum can be occupied by others
    • 10:00 ~ 11:00 - Give the heart to No. 2; (At this time, the heart is occupied by No. 1, so at this moment, No. 2 can only block the thread and wait until No. 1 returns the heart before executing the instructions of No. 2;
    • 11:00 ~ 12:00 - Give your heart to number two

    can still date like this

    • 8:00 ~ 9:00 - have dinner with number one;
    • 9:00 ~ 10:00 - Give your heart to No. 2; ❤ At this time, No. 2 occupies the old scumbag's heart. During the occupation, the thread is blocked. After returning this resource, the old scumbag's heart can be occupied by others
    • 10:00 ~ 11:00 - Give the heart to No. 1; (The thread is blocked and waiting, and the heart is occupied by No. 2 at this time, so at this moment, No. 1 can only block the thread in place and wait until No. 2 returns the heart ;)
    • 11:00 ~ 12:00 - have dinner with No. 2;

Asynchronous summary :

According to the above example, we can find that the dating tasks with No. 1 and No. 2 are equivalent to two processes, and the old slag is equivalent to a CPU executing the instructions of these two processes. Each process has its own instructions to be executed. . At the same time, the heart of the old scum is equivalent to limited system resources. Due to the limited resources that can be allocated, the execution of the process is not consistent to the end. In the process of advancing these processes, we found that they stop and go at an unpredictable speed. of.

Obviously, if concurrency is lost, the system can only process each process serially, and the execution of each process will be consistent to the end. Only when the system has concurrency can it be possible to derive asynchronicity.

Summary of this section

Airborne King

image-20220303210048761

According to the above study:

We learned the difference between concurrency and parallelism through the different strategies of big and small slags in dating;

At the same time, we learned that concurrency and sharing are the conditions for mutual existence through the example of sending files at the same time through QQ and WeChat ;

According to the above study:

We learned the difference between concurrency and parallelism through the different strategies of big and small slags in dating;

At the same time, we learned that concurrency and sharing are the conditions for mutual existence through the example of sending files at the same time through QQ and WeChat ;

Later, we learned about the concept and understanding of virtual and asynchronous. We know that virtual and asynchronous will not be extended without concurrency, and concurrency and sharing are the conditions for mutual existence. Then it can be explained that there is no concurrency and sharing. Virtual and asynchronous, so concurrency and sharing are the two most basic features of the operating system .

Guess you like

Origin blog.csdn.net/weixin_43654363/article/details/124068792