Subject: Embedded Engine and Multi-threading

From: Lalit Jain <[email-masked]>
Date: Wed, 31 May 2000 10:59:41 -0700 (PDT)

Hi All:

I am trying to use SWI-Prolog as an embedded engine in a multi-threaded
application. I want to create "multiple instances of prolog engine in a
single process" (for instance, each thread having its own prolog engine).
As a result, this would allow me to have each prolog engine load its
own set of rules/facts and execute goals.

My question is whether this is supported in the SWI-Prolog. If yes,
could you please tell how it can be done. If no, do you know of any
alternative to achieve this.

The SWI-Prolog reference manual says in sec. 5.6.10 on foreign code and
prolog threads:
"If you are using SWI-Prolog as an embedded engine in a multi-threaded
application you can access the Prolog engine from multiple threads by
creating an engine in each thread from which you call Prolog."

I'm not sure what exactly this means, whether I can create multiple
engines (one in each thread) or whether I could only create one engine but
access it from multiple threads by attaching the thread to that engine.

I have tried creating multiple threads and using
PL_thread_attach_engine() but it seems that only one
engine instance exists. But I am not sure if I have done the right way.

Any help in this regard would be greatly appreciated.

Thanks,
Lalit