One, process and thread Overview:
- Process, which is the basic unit of allocating and managing resources during the execution of a program that executes concurrently, each of which has its own address space.
- threads, which are part of a process, can be considered single-threaded by a process without threads. Threads are sometimes referred to as lightweight processes or lightweight processes, and are also a basic unit of CPU scheduling.
- Contact:
-
- The process has a complete virtual address space, independent of the thread and not dependent on the existence;
- a thread is part of a process that does not have its own address space and shares all of the resources assigned to the process with other threads in the process .
4. Difference:
-
- Each separate thread has a program run entry, sequence of sequence execution, and exit of the program. Threads cannot be executed, they must be dependent on the application, and the application provides multiple threads for execution control.
- A process is one execution of an application on a processing machine, which is a dynamic concept, and a thread is a part of a process that contains multiple threads running.
5. Execution characteristics of threads:
-
- A thread has only 3 basic states: Ready, execute, block.
- Threads have 5 basic operations to toggle the state of a thread: derive, block, activate, dispatch, end.
6. Process communication:
-
- There are 4 forms of process communication in a stand-alone system: Master-Slave, conversational, message or mailbox mechanism, shared storage mode.
- Master-Slave Typical example: Terminal control process and terminal process.
- Conversational Typical example: communication between a user process and a disk management process.
7. Multi-process and multi-threading:
Why do I need multiple processes (or multithreading) and why do I need concurrency?
Multithreading/process, like a fast-food waiter, both at the front desk to receive customer order, but also to answer the phone delivery, no ubiquitous will certainly be busy with your head.
Multi-process/threading technology is such a technology, so that you can be like the Monkey King, the soul out of the body, happy to easily deal with all the situation.
Concurrency is a technique that allows you to perform multiple tasks simultaneously at the same time. Your code will be executed not just from top to bottom, but from left to right in a straight line.
You can have a line in the main function to communicate with your customers, the other line, you have already sent your takeaway to other customers in the hand.
Python development "4th" "Processes, Threads"