Foreplay: The concept of processes and threads
If you learn Linux under the process, thread, signal ... will have a deeper understanding. So the recommendation to learn, including network programming can be understood, especially for Select,pool,epool will have more understanding.
A process is the smallest unit of resource management, and a thread is the smallest unit of program execution. A program can have multiple processes, and a process can have multiple threads executing concurrently
1. Process:
The operating system isolates the address space that each process can access. If you need to pass information between processes. Then you can use interprocess communication or other way, like signal, file, database, clipboard .... such as In a process's schedule, the event that the process needs to switch is much more. In order to better support information sharing and reduce switching overhead. Thus the threads evolved from the process.
2. Threads:
A thread is the execution unit of a process. For most programs, there may be only one main thread, which is the program process. In the system, it seems that all the threads are executed concurrently, in fact, to collectively seize the resources, when a thread is finished, the next use immediately, reducing the gap in time. is roughly the same as the process preemption time slice. But it still improves a lot of efficiency.
Example: When downloading a file, you can split the file into multiple parts and then use multiple threads to download at the same time, speeding up the download speed.
3. Comparison of process threads:
Python---Fundamentals review (10) Processes and threads