Home >Operation and Maintenance >Linux Operation and Maintenance >What is linux coroutine
Linux coroutine is a lightweight user-mode thread, and the operating system is unaware of the coroutine. Coroutines implement collaborative scheduling (non-preemptive scheduling), that is, coroutine switching is controlled by the current coroutine and actively gives up the CPU. Typically, a thread contains multiple coroutines.
Coroutine definition
(Recommended learning: linux tutorial)
Coroutine ), is a lightweight user-mode thread, and the operating system has no awareness of coroutines. What is implemented is collaborative scheduling (non-preemptive scheduling), that is, coroutine switching is controlled by the current coroutine and actively gives up the CPU (for example, when the current coroutine is waiting for asynchronous network IO).
Normally, a thread contains multiple coroutines.
Characteristics of coroutines
1. Coroutines are a concurrently running multi-task system, generally driven by an operating system thread;
2. Coroutine task metadata The resource usage is lower than that of operating system threads, and the task switching overhead is small;
3. Coroutines are collaborative scheduling between tasks, that is, one task actively gives up execution and then schedules another task to run.
The above is the detailed content of What is linux coroutine. For more information, please follow other related articles on the PHP Chinese website!