Skip to content
24 December 32008 / Robin Wellner

Thread Communication

The main problem I had with using threads was interthread communication. Luckily, the Stackless Channels solved most of the problems before they arose. But you still have the issue: which Tasklet must be able to talk to which.

It was obvious the Kernel Tasklet must be connected to every single other thread, but beyond that it’s more complicated.

You can’t just connect everything with each other. Ignoring the fact it may impose a security risk, with 50 Tasklets, not a very high number, 1225 Channels are needed. That’s right: over a thousand Channels for only fifty threads.

I considered letting the Kernel passing Channels around to Tasklets that requested it, but it would probably not be viable.

So what to do? Then, another idea came to my mind: which Tasklets (person threads, object threads, daemons…) need to interact with each other? Mostly only those which are in the same room. So, Tasklets only have a Channel to 1) the Kernel, 2) other Tasklets in the same room and 3) a Room Tasklet. With the same amount of Tasklets plus 5 Room tasklets, I get to a total of 357. Sure, it’s still a lot, but also a lot less than with the all-to-all approach, while giving each Tasklet enough means of communication.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: