The relationship between processes and threads and coroutines

process
Computer applications, is the process, it has its own address space
Includes a text area (text region) a data area (data region) and stack (stack region)
Code is executed by a processor stored text area; dynamically allocated memory area stores data used during execution process variables; stack area stores instructions and local variables of the calling procedure activities.
When the program is in blocking IO program will wait together. Three states ready, running and blocking
Thread
Stand-alone program fragment, typically in a process may comprise a plurality of threads, a process has at least one main thread, the thread may process resources have, in the introduction of the thread in the operating system, the process is usually assigned as the basic unit of resources, and the thread as a basic unit and a separate stand-alone scheduling, thread is smaller than the process, basically do not have the system resources, so it's scheduled pay costs, it will be much smaller, more efficient improve the degree program between concurrent execution of multiple systems.
Coroutine
Equivalent to micro-threads. A thread execution
Coroutine high efficiency. Since switching function subroutine is not a thread switch, but by the program itself, and therefore, without the overhead of thread switching, and multi-threaded ratio, the more the number of threads, the more performance advantages coroutine

Guess you like

Origin www.cnblogs.com/dawuge/p/11277711.html