# Theoretical Knowledge # Operating System Fundamentals # as the name implies, a process is a process that is being executed. The process is the concept of an abstract # process that is running a program originating from the operating system, the core concept of the operating system, and the most Ancient is one of the most important abstract concepts. All the rest of the operating system is built around the concept of process # > #ps: The ability to support concurrency is ensured by leveraging the CPU's own one. Turn a single CPU into multiple virtual CPUs # (Multi-channel technology: Time multiplexing and space multiplexing + Hardware isolation), without the abstraction of the process, the modern computer will no longer exist. # Essential Theory: #操作系统的作用: #1. Hides ugly and complex hardware interfaces, providing a good abstraction interface #2. Manage, schedule, and process multiple processes to the hardware The orderly #多道技术 of competition: #1. Background: For a single core, concurrency #2 is implemented. Reuse in space: if there is a multi-channel program #3 in memory. Time reuse: Multiplexing A CPU's time slice (switching back and forth) # What is a process # process is a program on a computer where a running activity on a data set is the system's resource allocation # and the basic unit of dispatch, which is the basis of the operating system structure. In the early stages, a process is the basic executing entity of a program, and in contemporary times, a process is a thread's # container. The program is an instruction The process is the entity of the program. #狭义定义: A process is an instance of a running program > #广义定义: A process is a program with a certain set of independent features that runs an activity on a data collection. He is the #基本单元 of the dynamic execution of the operating system, in the traditional operating system, The process is the basic allocation unit and the basic execution unit. #进程的概念: #1. The process is an entity. Each process has its own address space, typically including three: text area, data, push stack # text area is the code, the data area is the storage variable and the execution period Dynamically allocated memory, the # stack area stores the instruction and local variable #2 of the active call. A process is an executing program. A program is an inanimate entity, and only the processor gives the program life #它才能成为一个活动的实体, we call the process/# The reason why the operating system introduces the process concept: #从理论角度看, is the abstraction of a running program process; # from an implementation perspective, it is a data structure designed to clearly portray the inherent laws of dynamic systems. Effective management and scheduling of access to the computer system main memory running program. #进程的特征: #动态性: The essence is the procedure in the multi-channel program system, the process is a dynamic generation, dynamic de-busy #并发性: Any process can be executed concurrently with other processes. #独立性: A process is a unit of independent operation, but also an independent unit of system scheduling and allocating resources #异步性: Inter-process constraints, so that the process has a discontinuity of execution, that is, the process is driven forward by their independent, unpredictable speed #结构特征: program, data, Process control block # processes and areas in the program Do not: #程序是指令和数据的有序集合, is a static concept #而进程是程序在处理器上的一次执行过程, it is a dynamic concept #程序可以作为一种软件资料永久保存, and the process is a certain life cycle. #程序的永久的, the process is short-lived. #进程的调度: #当多个程序交替运行时, the operating system must dispatch these processes, which are not random, but follow certain principles #先来先服务调度算法: #短作业优先调度算法: # Time Slice Rotation method: #多级反馈队列: #进程的并发和并行: #并发: In the case of limited resources, the two alternate resources (such as single core CPUs) #并行: Both perform #注意两者区别 at the same time: #并行是从微观上, in a precise The same program executes #并发是从宏观上, and for some time it is seen that simultaneous # synchronous asynchronous blocking and non-blocking # creation---> Commit---> Ready (except CPU allocated to all other required resources)---->> process scheduling-->> Run--->> release ... Exit #--------<< time slice to << run # # block # Ready State: The process allocates all the necessary resources except the CPU for the program, as long as the CPU is obtained and executed immediately. # Execution Status: The status of the program executing on the processor # blocking state: Executing a program that is unable to execute because it waits for something to happen, discarding the processor and blocking, such as I/O wait signal # Synchronous and Asynchronous # Synchronization: The completion of a task must depend on another task is to wait for the dependent task to complete, the dependent task is completed, which is a #靠的任务序列. At the same time, the state of the two tasks can be consistent, either successfully or simultaneously. #异步: Do not rely on the waiting task to complete, just notify the dependent task to complete what work, the dependent task also immediately executes the #只要自己的任务完成整个任务完成, as to whether the dependent task is completed, It is not possible to determine that it is unreliable for the task sequence # blocking and non-blocking: #阻塞和非阻塞这两个概念与程序 (threads) are waiting for message notifications (regardless of synchronous or asynchronous) when the State is concerned. The # Synchronous/asynchronous and blocking/nonblocking #1 #也就是说阻塞与非阻塞主要是程序 (threads) waiting for a message notification. Synchronous blocking form: Low efficiency, is to concentrate on the line, what other things do not do #2. Asynchronous blocking form: The bank's people do business, a person receives a line note, This person can only wait to be unable to do other things #3. Synchronous non-blocking: while calling and observing the queue (switching back and forth), it is inefficient #4. Asynchronous nonblocking form: high efficiency. While waiting for the bank to wait for the call, the two different operations to switch back and forth #进程的创建和结束 #进程的创建 #凡是硬件都需操作系统去管理, as long as there is an operating system, there is the concept of process, you need to create a process, # There are four main ways to create: #1. The system initializes the #2. A process that opens a child process during operation #3. The user's interactive request creates a new Jinc #4. The initialization of a batch job (applied in the batch system of the mainframe) #进程的结束 #1. Normal exit #2. Error exits #3. Critical Error #4. Process to kill
Python Process Basics