Go: A new system programing language

Robert Jacques sandford at jhu.edu
Wed Nov 11 20:22:57 PST 2009


On Wed, 11 Nov 2009 20:03:37 -0500, Bill Baxter <wbaxter at gmail.com> wrote:

> On Wed, Nov 11, 2009 at 4:56 PM, Walter Bright
> <newshound1 at digitalmars.com> wrote:
>> hasenj wrote:
>>>
>>> Walter Bright wrote:
>>>>
>>>> Message passing for concurrency is a solid solution for many types of
>>>> concurrency problems, but it isn't a panacea.
>>>
>>> Do you think D would benefit if you add this (or similar) feature to  
>>> it?
>>
>>
>> Sean is working on a message passing (CSP) package for D. I'm not  
>> convinced
>> it needs to be a core language feature, though.
>>
>
> Is it possible to do the kind of "goroutine" scheduling they do purely
> as a library?
>
> That wasn't really clear to me how their "segmented stacks" thing
> works.  Sounds like it would need low-level runtime system support,
> though.
>
> --bb

Yes and no. At heart, they're basically co-routines or fibers, but with a  
grow-able stack. So the basic model can be done in a library (and is  
already in druntime, sans the CSP style message passing), but the  
compactness of a segmented stack are missing. And when you're creating  
100_000 fibers, memory compactness is key. I'm extrapolating, because I  
didn't see anything obvious on the website, but basically a segmented  
stack allows ESP (the stack pointer) to vary independently of EBP (the  
current stack frame pointer). This requires the stack frame to contain a  
'done' flag, it's size, etc, to allow memory reclamation (i.e. so the ESP  
can shrink), among other things.

However, a Cilk style task library is both possible and already available  
in D (see Dave Simcha's parallel foreach), and covers most of the examples  
in the videos; using fibers for simple tasks is overkill.

BTW, D currently requires: EBX, ESI, EDI, EBP must be preserved across  
function calls.

P.S. You might want to take a look at C++ CSP:  
http://www.cs.kent.ac.uk/projects/ofa/c++csp/



More information about the Digitalmars-d mailing list