table of Contents
@(process)
1. What is the process
Process (Process) is a computer program run on a set of data on the activities of the system is the basic unit of resource allocation and scheduling, is the underlying operating system architecture. In the computer architecture for the early design process, the basic process is the execution of the program entity; in contemporary computer architecture design for the thread, the thread is the process vessel. Program is instruction, organization of data and its description of the process is a solid program.
2. The process life cycle
Achieve 3.Python in multi-process
Code
import time
import multiprocessing
def test1():
while True:
print("---1-----")
time.sleep(0.2)
def test2():
while True:
print("---2-----")
time.sleep(0.2)
def main():
p1 = multiprocessing.Process(target=test1)
p2 = multiprocessing.Process(target=test2)
p1.start()
p2.start()
if __name__ == '__main__':
main()
note
Multi-threaded and can see no difference
4. The difference between processes and threads
What is the process, what is the thread
System to do one thing, to run a task, all running tasks is usually a program;
Each running program is a process, which can be seen in the image above task manager.
When a program is running, the internal order of execution may contain multiple streams, each stream is a sequential execution thread.
For example, a machine for multiple processes to open multiple qq
a qq open multiple chat windows for multiple threads
Thread execution overhead is small, but not conducive to the management and protection of resources. Instead process