The parent process and the child process can be executed concurrently; both the parent process and the child process are the smallest unit of resource allocation by the system. They are independent processes and can be run concurrently. Concurrency is not executed at the same time on a micro level. , just divide the time into several segments, so that multiple processes can be executed rapidly and alternately. From a macro perspective, it seems that these processes are all executing.
The operating environment of this tutorial: Windows 10 system, DELL G3 computer.
Can be run concurrently,Because both the parent process and the child process are the smallest unit of resource allocation by the system. Independent processes can run concurrently, which is different from the relationship between processes and threads.
"Parallel" means that both micro and macro are executed together, just like two people digging a hole with a shovel each. After one hour, each person A big hole.
"Concurrency" is not executed at the same time from a micro perspective. It just divides the time into several segments so that multiple processes can execute quickly and alternately. From a macro perspective, it seems that these processes are all Execution is like two people using the same shovel and taking turns digging a hole. After an hour, they each dig a smaller hole. If they want to dig two larger holes, it will definitely take two hours.
It is not difficult to see from the above essence that "concurrent" execution does not fundamentally improve execution efficiency when multiple processes have resource conflicts.
Father and son processes are concurrent.
In a single processor, multi-processing does not make much sense. Multi-tasking on a single processor can only be concurrent (polling alternately with time slices). At this time, macroscopically, it is multi-tasking. Running together is actually done in alternating time slices from a micro perspective. Therefore, although they are run together from a macro perspective, the time used to execute one process and one process does not save much. When there is a process that needs to be suspended or slept, there will be It may take a little longer, but if there is no suspend or sleep, the time may take a little longer, because it is also consumed by the continuous process conversion of the kernel in the time slice.
But in multi-processors, multitasking can really achieve parallelism. Multiple processes are executed on different processors. Only when resource conflicts and synchronization are needed, pause and wait for others. Time is truly executed asynchronously and simultaneously. But as mentioned above, when multiple processes have resource conflicts, execution efficiency is not fundamentally improved.
For more related knowledge, please visit theFAQcolumn!
The above is the detailed content of Can the parent process and child process execute concurrently?. For more information, please follow other related articles on the PHP Chinese website!