From: David S. <da...@da...> - 2004-04-28 06:56:48
|
The following message is a courtesy copy of an article that has been posted to comp.lang.lisp as well. I've glanced through the SBCL manual for things outside the ANSI spec. For instance, I am interested in threaded programming using sb-thread. While I am sure that apropos and describe are good for reference purposes (or at least brief reminders), I am looking for a gentler introduction to threaded programming with SBCL's sb-thread. I've done simple threaded programming with the Win32 API and Java, but that was a while back. I know in general about things like synchronization/serialization, race hazards, and deadlocks. What I don't know is how these are handled with sb-thread. To quote a line from the SBCL manual: "Dynamic bindings to symbols are per-thread. Signal handlers are per-thread." Although I have not seen how Lisp does signal handling, it is nice to know that the handler will be called in the same thread that the signal was raised. That at least means that you can pretend the thread is its own little world. I'm not quite sure about the dynamic bindings. My interpretation is that (defvar *foo* "bar") means that every thread has *foo* with the initial value of "bar". If a thread does (setf *foo* "baz") then /that/ thread and /only/ that thread has *foo* bound to "baz". If this is the case, then that is great. I have a sort of thread local storage thing going on for free. That then leads me to wonder how to create a shareable object such as a hash table (or an a-list) that has serialized access from all the threads that need to touch it in some way. Then there are other threading issues like waiting on objects (Java style) and other scheduling issues. For example, if thread creation has too much overhead for a given purpose, I would want to pre-spawn a number of threads and have them sleeping in a queue to be woken up as needed to handle a request and then go back into the queue when finished rather than exiting. I still consider myself very much a Lisp beginner (neolisper?). I kind of skipped through macros and clos in Graham's ACL book. I figured I could come back to that stuff. I am hoping that I have enough ground work to handle seperate concepts such as threads and also sockets and other things. -- I wouldn't mind the rat race so much if it wasn't for all the damn cats. |