Python-Introducing the concept of process and concurrency from the operating system

1. What is the process

As the name implies, the process is the process of program execution, and the process is an abstract understanding of the running program.
The concept of process originated from the operating system. It is the core concept of the operating system and one of the oldest and most important abstract concepts provided by the operating system. Everything else in the operating system is developed around the concept of processes. So if you want to really understand the process, you must know the operating system in advance.

Two, operating system

In short, the operating system is a control program that coordinates, manages, and controls computer hardware resources and software resources. The location of the operating system is shown below;
Insert picture description here

In detail, the operating system can be divided into two parts:

System interface and operating system kernel

  1. Hide the ugly hardware call interface, and provide application programmers with a better, simpler, and clearer model (system call interface) for calling hardware resources. After application programmers have these interfaces, they no longer need to consider the details of operating hardware, and can concentrate on developing their own applications.
例如:操作系统提供了文件这个抽象概念,对文件的操作就是对磁盘的操作,
有了文件我们无需再去考虑关于磁盘的读写控制,比如控制磁盘转动,
移动磁头读写数据等细节;
  1. Order the application's competing requests for hardware resources,
例如:很多应用软件其实是共享一套计算机硬件,比方说有可能有三个应用程序同时需要申请打印机来输出内容,
那么a程序竞争到了打印机资源就打印,然后可能是b竞争到打印机资源,也可能是c,这就导致了无序,
打印机可能打印一段a的内容然后又去打印c...,操作系统的一个功能就是将这种无序变得有序。

3. The history of operating system development

Operating system history

Four, multi-channel technology

The multi-channel technology in multi-channel technology refers to multiple programs. The realization of multi-channel technology is to solve the orderly scheduling problem of multiple programs competing or sharing the same resource (such as cpu). The solution is multiplexing. Multiplexing is divided into multiplexing in time and multiplexing in space.

1. Background

For single-core CPUs, concurrency can be achieved;
current CPUs are generally multi-core, and each core uses multi-channel technology;

2. Spatial reuse

The codes of multiple programs can be stored in the memory, and they are physically isolated;

3. Time reuse

Reuse the time slice of a cpu;
in case of io switching, if the cpu time is too long, the core is to save the state of the process before switching, so as to ensure that the next time you switch back, you can continue based on the position of the last switch. run;

如果我们的核心目标是想让多个任务并发起来:那么无论是遇到IO还是没有遇到IO都应该让cpu在多个任务之间切换起来

如果我们的核心目标是想让多个任务的运行效率提升:我们应该只控制一个任务在遇到IO情况下切换到另外一个任务

Guess you like

Origin blog.csdn.net/msmso/article/details/108130113