Process is the basic unit of resource allocation. It is an instance of program execution and is created when the program is running. Thread is the smallest unit of program execution and is an execution flow of the process. One thread consists of multiple threads. consist of.
What is a process
A process is the basic unit of resource (CPU, memory, etc.) allocation, it is a program An instance at execution time.
When the program is running, the system will create a process, allocate resources to it, and then put the process into the process ready queue.
When the process scheduler selects it, it will allocate CPU to it. time, the program starts to actually run.
What is a thread
A thread is the smallest unit of program execution. It is an execution flow of the process and a CPU scheduler. and assigned basic units.
A process can be composed of many threads. All resources of the process are shared between threads. Each thread has its own stack and local variables.
Threads are scheduled and executed independently by the CPU, allowing multiple threads to run simultaneously in a multi-CPU environment. Similarly, multi-threading can also implement concurrent operations, and each request is assigned a thread to process.
The above is the detailed content of What are processes and threads. For more information, please follow other related articles on the PHP Chinese website!