[fpc-devel] Protothreads for UNIX (maybe for FPC?)
Graeme Geldenhuys
graemeg.lists at gmail.com
Mon Jan 19 08:24:31 CET 2009
I thought somebody might find this interesting. And it's only 400
lines of C code.
Originally posted at:
http://osnews.com/story/20793/Protothreads_for_UNIX
Protothreads [http://en.wikipedia.org/wiki/Protothreads] are a type of
extremely lightweight threads - each protothread requires only two
bytes of memory - that are usually used for embedded firmware
programming, where memory is at a premium. Protothreads combine the
low overhead with event-driven programming with the algorithmic
clarity [http://www.sics.se/~adam/dunkels06protothreads.pdf] of
threaded programming.
Larry Ruane from LeftHand Networks Inc. has written a protothreads
library for Unix systems [http://protothread.wiki.sourceforge.net/]
that, unlike Adam Dunkels' original library, contains a complete
scheduler that allows several protothreads to run inside a regular
thread. Ruane's protothreads are implemented in less than 400 lines of
C code using gcc's labels-as-values
[http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html] feature. The
project wiki [http://protothread.wiki.sourceforge.net/] has a thorough
explanation of how protothreads work and how they are intended to be
used. The open source code can be downloaded from the project's
SourceForge page
[http://sourceforge.net/project/showfiles.php?group_id=248874&package_id=304459].
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
More information about the fpc-devel
mailing list