In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about the differences between swoole processes and threads. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Differences: 1, the process is a running program in the system, while the thread belongs to the process, a process can have multiple threads, and the thread is the executor in the program; 2, no state is shared between processes, and variables can be shared between threads.
Operating environment of this tutorial: Windows10 system, Swoole4 version, DELL G3 computer
What is the difference between swoole processes and threads
Process
1. No state is shared between processes
2. The scheduling of the process is completed by the operating system
3. Each process has its own independent memory space
4. Inter-process communication is mainly realized by signal transmission, which can be realized in many ways, such as semaphores, pipes, events and so on. The communication efficiency of any method needs to go through the kernel, resulting in low communication efficiency.
5. Because it is an independent memory space, it is necessary to save the information of calling stack, cpu registers, virtual memory, and open related handles during context switching, which leads to high overhead and troublesome communication between context processes.
Thread
1. The variable is shared between threads, which solves the problem of communication. The access to the variable needs to be locked.
2. A process can have multiple threads, but each thread will share the parent process, such as the operating system application resources, including virtual memory, files, etc., because it is a shared resource, so the system resources required to create threads are much smaller than the process, and the corresponding number of threads that can be created has become relatively large.
3. In addition, in terms of scheduling, because the memory is shared, there are fewer things that need to be saved during context switching, so the context switching becomes efficient.
What is the process?
A process is a running program in the system, and once a program is run, it is a process.
A process can be seen as an example of program execution.
Tags: one process cannot access another process's variables and data structures. If you want one process to access another process's resources, you need to use inter-process communication, such as pipes, files, sockets, etc.
What is a thread?
Threads belong to the process and are the executors of the program.
A process contains at least one main thread, or there can be more child threads, each using the stack space of the process to which it belongs.
A thread is an entity of a process and an execution path of a process.
Tags: multiple threads within the same process share part of the state, and multiple threads can read and write the same block of memory.
These are all the contents of this article entitled "what are the differences between swoole processes and threads?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.