Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Coroutine
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Threads=== Coroutines are very similar to [[Thread (computing)|threads]]. However, coroutines are [[cooperative multitasking|cooperatively multitasked]], whereas threads are typically [[Preemption (computing)|preemptively multitasked]]. Coroutines provide [[concurrency (computer science)|concurrency]], because they allow tasks to be performed out of order or in a changeable order, without changing the overall outcome, but they do not provide [[parallel computing|parallelism]], because they do not execute multiple tasks simultaneously. The advantages of coroutines over threads are that they may be used in a [[hard realtime|hard-realtime]] context ([[context switch|switching]] between coroutines need not involve any [[system calls]] or any [[blocking (computing)|blocking]] calls whatsoever), there is no need for synchronization primitives such as [[mutex]]es, semaphores, etc. in order to guard [[critical sections]], and there is no need for support from the operating system. It is possible to implement coroutines using preemptively-scheduled threads, in a way that will be transparent to the calling code, but some of the advantages (particularly the suitability for hard-realtime operation and relative cheapness of switching between them) will be lost.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)