Hi, Michael.

I gathered that you've been away.  Hope everything is going well at
BBC Research.

I've been going over several architectural models for Dendrite lately.
 It seems that, just as soon as I nail down one architecture and get
it implemented / tested, several new ideas occur to me.

My latest realization with the 0.9 release is that, in trying to glue
Dendrite the OS level I almost created another Turing-complete
implementation of Dendrite.  I think that sort of infinite recursion
is what's know as the Turing Tarpit.  Generalizing your application
solution and then trying to generalize that.

:-)

In either case, since my OS connection layer needed a complete mailbox
system itself I figured that I would force myself to eat my own dog
food and implement the OS glue using Dendrite itself with a new async
component method I devised.  This would allow me to create Console,
Session and CLI components that run within Dendrite.

The trick with the async components so far is that I have to introduce
a "wait" primitive that handles the differences between POSIX and
Windows IO Requests.  Now that I have that solved, one of the clever
library developers just *had* to ask me if my library would work
multi-core.

Of course that question clarified some of the questions I'd been
asking myself.  What would the correct Dendrite architecture look like
if it ran multi-threaded, multi-core.  It turns out that the answer to
that solved other issues I've been having.

Since Dendrite is a message passing system, making the handlers into
async components cleans up the multi-core issues.

Also (and I think this part is pretty fascinating) one of the problems
with multi-threaded code is that to communicate between threads
requires a thread-safe mailbox.

It turns out that there are such things.  The simplest of course is to
use mutex locks around the critical mailbox send/receive code.  But
mutexes are inefficient because they cause re-scheduling of the
blocked process.

So you use a lock-free mechanism, but those are rare and somewhat
complex beasts.  However there is a relatively simply mechanism that
allows a single-thread writer and single-thread reader (or
sender/receiver etc).  It's a lock-free ring buffer.  Normally the
one-writer, one-reader mechanism would be a limitation, but since each
Dendrite thread executes many cooperating components based on
co-routines it works out wonderfully.

I even found a high-speed ring buffer that is cache coherent, so that
sibling threads (threads running on cores on the same CPU) are able to
communicate, thread-safe, at very high speeds.

Anyway, you can see I'm kind of excited about all of this.  The beauty
of this is, with a few changes to the way the async components work
and a new mailbox that is thread safe (at least to other threads), I
can make this thing scale way, way up.

Then I'm really, really going to get back to the app I was writing
that I needed to write a messaging system for.  :-)

Jim


On Mon, Apr 12, 2010 at 9:37 AM, Michael Sparks <[email protected]> wrote:
> Hi Jim,
>
>
> On Mon, Mar 29, 2010 at 9:27 PM, Jim Burnes <[email protected]> wrote:
>> Kamaelia People,
>>
>> I've already sent this to Michael, but I thought I'd forward it to the group
>> because we're all in different time zones...
>
> I've been away from connectivity for the past couple of weeks, but now
> that I'm back I'd just like to say congratulations! :-) I'll try and
> take a look at my earliest opportunity. I've not used D, but this will
> be a nice introduction :-)
>
> Best Regards,
>
> Michael
>
> --
> You received this message because you are subscribed to the Google Groups 
> "kamaelia" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/kamaelia?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"kamaelia" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/kamaelia?hl=en.

Reply via email to