From: "Zed A. Shaw" Date: 2005-09-27T09:33:45+09:00 Subject: tuple-space patterns and lock-free data structures (was: Ruby Threads 101) Ben, I had a lot of fun implementing the following patterns as a way of avoiding almost all Thread primitives in a distributed video processing system and boosting performance quite a bit: http://alumnus.caltech.edu/~croft/research/agent/tuplespaces/ In fact, Ruby comes with a nice tuple space implementation, so you could take the above patterns, implement single instance versions, and then try to distribute them. Those patterns are also good examples of why the logical proof of single machine thread primitives does not instantly extend to distributed processing. They are much simpler to use and do exactly the same thing as distributed locking with nothing more than simple tuple-space semantics rather than the complicated mutex and semaphore semantics. I would also take a look at the work done on lock-free data structures and algorithms. Lots of really great stuff that basically shows you don't need locking on many data structures. Even more proof that 1970's locking technology needs to be rethunk. My favorite fun project is doing a Replicated-Worker pattern with just message queues. Sure the Queue needs locking, but why do you need to know that? Enjoy! Zed A. Shaw http://www.zedshaw.com/ On Tue, 27 Sep 2005 04:31:42 +0900 "Robert Klemme" wrote: > Joe Van Dyk wrote: > > On 9/26/05, James Edward Gray II wrote: > >> On Sep 26, 2005, at 12:37 PM, Ben wrote: > >> > >>> I looked through rubyquiz.com (where I've been pulling a few of > >>> our exercises), but nothing jumped out at me. Did I miss > >>> something? > >> > >> Glad to hear it's proving useful. > >> > >> We haven't had a good threading problem yet, but I'm very open to > >> the idea if someone can think one up... > > > > I have one about a bunch of hungry commie philosophers... > > LOL > > Ben, you could start with a simple problem (like farmer worker e.g. a > small app that crawls web pages in parallel with controllable degree > of parallelism) to get the basic feeling and then work your way up to > more complicated things. > > I once cooked something up on the Wiki (including a superfluous queue > implementation - there is one that comes with Ruby) although I guess > it won't be much use for you as you seem to be rather senior when it > comes to threading. > http://www.rubygarden.org/ruby?MultiThreading > > One thing to keep in mind is that Ruby threads are not (yet) native > threads. Despite of that they work quite nicely IMHO. > > Kind regards > > robert > >