GC and Threading
Pascal J. Bourguignon
pjb at informatimago.com
Sun Oct 25 12:33:58 UTC 2015
On 25/10/15 09:28, Bix wrote:
> just two quick question:
> 1. Is it possible to disable the threading model and have multiple thread
> to eval the code or have one ECL per thread?
Not, yes, probably not.
reading cl_boot should be instructive.
Being able to have several ECL instances per process could be
interesting: you would have multiple heaps, managed in different
threads, and some lisp data could be shared from one instance to another
(with some interesting consequences on teh garbage collection occuring
in each instance). There would also be some fun with signals, if having
to deal with them between ecl and the host program wasn't enough fun
Or alternatively, if you manage a single heap, why would you want to
have several instances?
> 2. Can the garbage collector be disabled at all and have the memory
> managed in a reference counting fashion?
Ecl uses Boehm GC, so it's rather modular, and I guess you could link in
a stub library.
You could add a dealloc function, and manage the memory manually. Good luck.
> I like to embed the ECL in my multithread application but I've got very
> restrictive constrain about thread and memory:
> * I can not spawn new thread but I've got concurrent thread to execute
> ecl call.
Ecl doesn't create any thread on its own. Only lisp programs may do so.
Do not use libraries that create threads and you'll be ok.
> * A component that bring GC would probably not be accepted
Then I would suggest to resign and find a better job.
Because, yes, you can disable the garbage collector,
but I wouldn't wish that on my worst enemy.
> and I'm
> wondering if there is an alternative to that in ECL, or at least have
> more control how/when GC will be run.
BoehmGC doesn't seem to offer a lot of options there.
It has the option to use a generational garbage collector.
> Can you point me out where to look in the source code to understand those
> aspect of ECL?
src/bdwgc contains a copy of the Boehm-Demers-Weiser Garbage Collector
src/bdwgc/include/gc.h shows the API you could implement or stub to
disable it from the point of view of ecl.
Notice that it's mostly GC_MALLOC, and there's a GC_FREE (never used in
ecl, you you would have to provide a lisp function calling it to free
the lisp objects).
(And don't count on reference counting, most lisp data structures are
__Pascal J. Bourguignon__
More information about the ecl-devel