From: Stephen White Date: 2001-02-13T01:18:44+09:00 Subject: [ruby-talk:10729] Re: Suggestion for threading model On Mon, 12 Feb 2001, Ben Tilly wrote: > Secondly synchronization requires locking. If you have automatic locking > going on then it either needs to be very coarse-grained (in which case you > do not get good concurrency) or else it is fine-grained in which case you > wind up with a lot of possibilities for deadlocks. You can only have deadlocks when there's resource contention. If the code is written sequentially with the interpreter parallelising where it can, then it's just the same as a CPU executing instructions out of order. > Instance variables are themselves threads. What if my object assumes that > my instance variables stay put while I am accessing them? I don't understand about instance variables being threads in their own right. An object would only have one thread so nothing has changed within the Object. The multi-threading is only between Objects. > Likewise many will (I certainly would) assume that if I make 3 method > calls in order that they will happen in order. They would, courtesy of single thread. > What if an instance variable of the object is busy? In some sample code > that I sent you that could happen. The object thread has to supply the instance variable, so the ordering is still assured. > Scenario. A calls B, B yields to a block that calls A again. Do we now > have deadlock? Good question. It could be handled by running two threads, which makes Ruby capable of handling streams, like sh scripting, or B's thread could be used to execute passed blocks like the way Ruby is now. > An idea I have heard very good things about in the Perl world which might > fit very well indeed into Ruby is POE. Makes me cringe like every other multithreading scheme I've seen. :) > For more of my thoughts on threading, see > http://206.170.14.76/index.pl?node_id=29620 > http://www.bitmover.com/talks/cliq/slide01.html Your thoughts amd that slideshow are based on OS threading. I'm proposing Object threading, which would operate like processes running in a CORBA environment, just a lot easier and a lot faster. Any out of order problems would be between processes. Any code or data accesses within each process would still be sequential, including instance variable accesses. -- spwhite@chariot.net.au