[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
I just came across this interesting little hack by Simon Tatham, which is used
to produce lightweight pseudo-coroutines in C:
http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
The rationale given for developing this system is to improve the readability of
code that is naturally concurrent (the example given is a classic producer
consumer) without having to invoke the full weight of threads. This approach
even results in CSP-style blocking on communications between the routines :)
The implementation is fairly limited (and obviously it would easier to write the
target programs in occam ;) but it does provide an extremely lightweight
mechanism for writing fully portable pseudo-concurrent code in pure C.
Adam Dunkels has apparently developed a lightweight "threads" library for use in
highly constrained embedded systems, based on the same coroutine ideas
(http://www.sics.se/~adam/pt/index.html). Presumably a library of CSP
primitives would be fairly easy to implement as well.
Allan
--
Allan McInnes <amcinnes@xxxxxxxxxx>
PhD Candidate
Dept. of Electrical and Computer Engineering
Utah State University