| Newsgroups |
gmane.lisp.scheme.chicken |
| Message-ID |
<[email protected]> |
> > > You are doing nothing wrong, it is just a limitation of the runtime system.
> > > CHICKEN expects callbacks to be invoked in the same thread as the
> > > one that invoked CHICKEN_run()/CHICKEN_initialize(). During
> > > initialization, stack-limits are inferred to ensure the generational
> > > garbage collector sees when the nursery is exhausted. Different
> > > thread have of course wildly different stack addresses, so this
> > > will confuse the garbage collector. You could say that this is a severe
> > > shortcoming (not necessarily a bug), and we could try to set the limits on
> > > every external call-in into the runtime system.
>
> Would this work with CRUNCH? If yes, then this is my excusive to give it a try.
Yes, the scenario should work, as CRUNCHed code doesn't use the CHICKEN
runtime system (unless you specifically perform callbacks into compiled
CHICKEN code, but then you are back to where you started). Running
CRUNCH-compiled code concurrently from different threads is not
supported yet (the refcounting is not atomic, something I still have to
address).
>
> My goal is to rewrite a state machine component in Scheme for runtime
> monitoring of multithreaded programs. I guess that I'll only need very
> basic features from the language, so CRUNCH could potentially work.
Then that sounds like a good alternative.
>
> > > There is an egg ("concurrent-native-callbacks") that addresses
> > > this very issue (calling from multiple threads into compiled
> > > CHICKEN code). It is not as elegant or clean as calling from
> > > multiple threads directly, but it is at least one possible approach.
>
> I took a look at this library and I think I could use it as plan B.
>
> The problem is that the monitoring library I'm working on captures the execution
> of threads. Adding an extra thread (dispatcher) will probably cause a lot of
> corner-case checking.
Indeed. So give CRUNCH a try, this might be a possible solution. Note that
it is still quite young and will contain bugs, so make sure to report any problems
you encounter.
cheers,
felix