This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Coroutines with call/cc


On 7 May 1999, Mikael Djurfeldt wrote:

> "Peder Chr. Norgaard" <pcn@tbit.dk> writes:
> 
> > The cost of the guile thread is in terms of memory:  each
> > thread needs a large piece of RAM that to allow for any possible stack,
> > both C and Scheme.  That is fine for heavier things like multiplexing
> > network traffic, for instance, but too expensive for an arbitrary data
> > access tool.
> 
> You can tell Guile how much memory to allocate for threads.
> 
>   (eval-set! stack <n>)
> 
> where <n> is the size of the stack in words.

I know that.  What I don't know and can't compute in general is how great
a value for <n> I must choose to avoid stack overflow - which kills the
thread on good systems and entire the interpreter on bad systems.

So to be on the safe side, I have to estimate a rather large value - and
that makes threads something that I don't want to allocate a large number
of.

(in earlier versions of Guile the value had to be large enough to
accommodate a garbage collection!  Fortunately the garbage collector is
now using it's own data structures and not the stack of the arbitrary
thread that was unlucky enough to get to do the collection)

I guess this is pretty hard problem to solve in general.  Simula (and
perhaps Java? I do not know for sure) avoids the problem by maintaining
the thread stacks as linked lists on the heap.  But that is not
something Guile can be made to do easily, as Guile is really using the C
stack for the Scheme stack.  It is also quite expensive - each function
invocation adds a piece of work to the garbage collector.

best regards

				--peder chr.

Peder Chr. Nørgaard                   System Developer, M. Sc.
Telebit Communications A/S            tel: +45 86 28 81 77 - 49
Fabrikvej 11                          fax: +45 86 28 81 86
DK-8260 Viby J   Denmark              e-mail: pcn@tbit.dk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]