{{htmlmetatags>metatag-robots=()
metatag-title=(Implementations on MIDRES Library | Multithreading on retrocomputers)
metatag-keywords=(Multithreading,Commodore 64,Commodore VIC20,Atari,Commodore128,MIDRES Library,6502,6510)
metatag-description=(How to implement fast and efficient multithreading on computers with limited resources.)
metatag-media-og:image=(:mt6502.png)
metatag-og:title=(Implementations on MIDRES Library | Multithreading on retrocomputers)
metatag-og:description=(How to implement fast and efficient multithreading on computers with limited resources.)
}}
====== Multithreading on retrocomputers ======
===== HOW ARE THEY IMPLEMENTED IN THE MIDRES LIBRARY? =====
Protothreads are implemented with macros that represent "annotations", using so-called "local continuations". Furthermore, they can also be used independently of MIDRES' graphic primitives.
A "local continuation" represents the current execution state at a particular point in the program, but does not provide any call history or local variables. You can set a local continuation in a specific function to capture the state of the function. Once a local continuation has been set it can be used to restore the function "state" to the point where the local continuation was set.
Local continuations can be implemented in various ways:
* using "machine specific" assembler code;
* using standard C constructs, or
* using compiler "extensions".
In the implementation on the MIDRES library, the standard C language option has been chosen, which requires only two bytes of status for protothread and uses the C "switch" instruction in a non-obvious way. The counterpart is the inability to use the switch statement in the code.
To learn more, see the [[http://dunkels.com/adam/pt/|protothreads library]] written by Adam Dunkels with the support of Oliver Schmidt.
[[:mt6502|Move to index]].