Luke Gorrie luke@bluetail.com writes:
HELP, HELP! SAVE ME! I don't know how to write correct multithreaded programs!
How do people do synchronization in Lisp? Do you use higher-level abstractions than locks and shared variables, or is there some book I can read to actually understand how to program with those things?
Okay, so your claim of ignorance that is probably largely tongue-in-cheek, but just in case, Doug Lea's, _Concurrent Programming in Java_ is pretty good despite the obvious Java focus. And you definitely want to check out Hoare's paper, _Monitors: An Operating System Structuring Concept_[1] if you haven't already.
The mind boggles. Please someone stop me before I write a homebrew message-passing system.
It seems to me that you want to make your own event queue--have the single thread doing the IO and putting work requests on queues for other threads to pick up and actually do the work. (To the extent I understand Erlang, this should be quite familiar--you just have to roll it yourself. Though there may be certain data structures other than the queues that need to be accessed concurrently which makes it less like Erlang. Again, as I understand Erlang which is not very much at all.) Of course that may be what you meant by a homebrew message-passing system. In which case, go for it.
-Peter
[1] http://www.acm.org/classics/feb96/