In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the scheduling mode of swoole collaborative process". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the scheduling mode of swoole collaborative process".
In swoole, because the switching of co-programs is serial, only one co-program can be run at the same point in time. When one co-program is running, other co-programs will stop working, so the swoole co-program is based on single thread.
Operating environment of this tutorial: Windows10 system, Swoole4 version, DELL G3 computer
Why swoole Protocol is single Thread
To put it simply, a cooperative program is a kind of lightweight thread that the programmer implements under the thread and cooperates with the lighter concurrency.
With the increase in the number of programmers, bosses also continue to explosive growth, of course, some people began to think that threads are not easy to use, then what to do? Of course, it is based on the concept of threads to implement a set of lightweight threads that are lighter and easier to deceive star (in fact, co-routines cannot be completely considered threads, because a thread can have multiple co-routines).
The difference between a cooperative program and a thread
Essence
Thread kernel state
Cooperative user mode
Dispatching mode
The scheduling mode of threads is system scheduling, and the commonly used scheduling strategies are time-sharing scheduling and preemptive scheduling. To put it bluntly, the scheduling of threads is completely out of their own control.
The scheduling mode of the cooperative program is collaborative scheduling, which is not controlled by the kernel and switched by free policy scheduling.
As mentioned above, the collaborative program is in user mode, so the so-called collaborative scheduling can be directly understood as the scheduling method written by the programmer, that is, I can schedule whatever I want, without having to be scheduled through the system kernel.
A shallow understanding of the cooperative process of swoole
Since we intend to get into the understanding of swoole's co-program, we must know the swoole's co-program model.
The cooperation process of swoole is based on single thread. It can be understood that the switching of the co-program is serial, and only one co-program is run at the same time.
The co-program of Swoole is single-threaded in the underlying implementation, so only one co-program is working at a time, and the execution of the co-program is serial. Unlike threads, multiple threads are scheduled by the operating system to execute in parallel with multiple CPU.
When one co-program is running, other co-programs stop working. The current protocol hangs when it performs a blocking IO operation, and the underlying scheduler enters the event loop. When there is an IO completion event, the underlying scheduler resumes the execution of the corresponding co-program.
The utilization of CPU multicore still depends on the multi-process mechanism of Swoole engine.
Thank you for your reading, the above is the content of "what is the scheduling mode of swoole cooperation program". After the study of this article, I believe you have a deeper understanding of what the scheduling mode of swoole cooperation program is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.