[Fwd: Re: [cells-devel] Cells and Threads]

Ken Tilton kentilton at gmail.com
Wed Feb 21 02:18:12 UTC 2007



Duane Searsmith wrote:

> Hi --
>
> Quick question.  I skimmed through the archives and didn't see any 
> obvious answer to this question. Is cells thread safe?  If not, is 
> there a particular pattern of use that one can follow to avoid 
> problems in a multiprocess scenario?
>
> I have an application that is multithreaded and I would like to 
> explore how to use cells to drive the dataflow.  I've read through the 
> examples and looked over the code a bit. Seems like I could get in 
> trouble if multiple threads tried to change a cell with dependencies 
> at the same time.
>
> If this is a silly question and I have missed some obvious explanation 
> somewhere, please just point me in the right direction.

Not at all, good question, I have been waiting for it. :) I am afraid I 
have never programmed a threaded application, so I do not know what to 
say. Can threads enqueue on some resource (in the case of Cells, that 
would be the "data pulse", just a sequential counter of state changes 
that drives data integrity)? That would do the trick (I think!), but 
then does that defeat the whole point of threads? If each thread 
operates on a discrete subset of the application universe, well, I /did/ 
start to mess with allowing such a beast to have its own pulse -- then 
we just have to figure out the boundary (assuming one wants at least 
/some/ dependency to reach thru the wormhole, if you will).

Hmmm, I guess if you are worried about two threads setting the same 
input cell then clearly they can enqueue on some resource. I guess the 
next problem is if you want to have the Cells engine itself running in 
multiple threads, which could be tough. And in /my/ Cells apps, Cells 
tend to ineluctably take over the whole application, so if Cells runs in 
one thread only then again -- well, like I said, I have never programmed 
with threads. I guess I will leave the implications to you.

Any help?

ken





More information about the cells-devel mailing list