From lalit@tdiinc.com  Wed May 31 19:59:48 2000
Received: from oahu.tdiinc.com (oahu.tdiinc.com [206.40.33.137])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id TAA15304
	for <prolog@swi.psy.uva.nl>; Wed, 31 May 2000 19:59:46 +0200 (MET DST)
Received: from neptune.tdiinc.com (neptune.tdiinc.com [10.1.4.46])
	by oahu.tdiinc.com (8.9.3/8.9.3) with ESMTP id LAA02292;
	Wed, 31 May 2000 11:00:44 -0700 (PDT)
Received: from localhost (lalit@localhost)
	by neptune.tdiinc.com (8.9.0/8.9.0) with ESMTP id KAA28774;
	Wed, 31 May 2000 10:59:41 -0700 (PDT)
X-Authentication-Warning: neptune.tdiinc.com: lalit owned process doing -bs
Date: Wed, 31 May 2000 10:59:41 -0700 (PDT)
From: Lalit Jain <lalit@tdiinc.com>
To: prolog@swi.psy.uva.nl
cc: Lalit Jain <lalit@tdiinc.com>
Subject: Embedded Engine and Multi-threading
Message-ID: <Pine.GSO.4.21.0005311039460.6196-100000@neptune.tdiinc.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII


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


