coprocessor (Coroutine) and Threads (thread) One of the common purposes of the coprocessor and thread
differences is to implement the context invocation of system resources, but their implementation levels are different;
A
thread (thraed) is a running unit that is smaller than the process level. Multi-threaded implementation of system resource context calls, is the programming language delivery system kernel to carry out (may be concurrent, may also be pseudo concurrency), most of the multithreaded implementation of programming language is preemptive, and for these threads of control , the programming language cannot be directly controlled, it needs to be done through the system kernel, and the final behavior is determined by the system kernel.
Coroutine is the process of implementing "multithreading" at the language level, which generally expresses concurrent logic in a serial way in code, because it simulates this process at the programming language level, rather than the hardware level, which can be completely controlled at the programming language level, so to speak, The coprocessor is a software level simulation hardware layer of multithreading, but not that the coprocessor must be a single thread, the realization of the specific programming language to see the implementation of the Kotlin can be a single thread, but also may be multi-threaded;
The usage scenario of the coprocessor can be used to solve the high load network io, file io, Cpu/gpu intensive tasks, etc.
For example, in an IO-thread-loaded scenario, CPU resources are consumed by a large number of threads, which can be a huge waste of CPU resources, and may cause some important threads to be blocked, the cost is very expensive, at this time, if using IO coprocessor instead of IO threads, can greatly reduce the number of threads, save CPU resources, At the same time, there is almost no cost in the coprocessor (no context switching or OS intervention is required), while the programming language has great control over the coprocessor.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.