[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: multithreading
From: |
Joseph Benden |
Subject: |
RE: multithreading |
Date: |
Sat, 1 Dec 2001 06:56:54 -0500 |
I am
pretty sure the GNU Prolog is not thread-safe in how you are calling it.
This is what I am doing with success:
On
Linux: I am using multiple process (a preforking) server, and after the
accept and fork, then call Start_Prolog.
On Windows: I have the GNU Prolog wrapped into a
DLL. On the DLL_PROCESS_ATATCH I call Start_Prolog. Then each thread waits
on a master critical section before calling any prolog routines (inside the dll,
on each call).
I do
not believe GNU Prolog is thread-safe because it uses global memory
space for its' stacks. If you only ever read the memory, you should
be safe, but writing is a different story. One could put mutex locks in
the term reading and writing functions. But that would be a big project,
and would slow the prolog down. GNU Prolog would have to use
thread-local stacks, but that would require a re-write of the
entire prolog, and would make multiple thread unable to access other
threads stacks.
To get
the same performance under windows as linux, load multiple instances of the DLL
and marshal into them.
Joseph Benden
Systems Development/Network
Administrator
Hi,
Is the gprolog interface
thread-safe? I seem to be having problems trying to use it with the pthread
library on Linux. I'm using gprolog-1.2.1 on a Linux box. The particular
problem that I face is that if I call Start_Prolog() in one thread and the
other calls in a second thread , the program gives a segmentation violation.
The
second problem that I face is that if I call Start_Prolog() , Stop_Prolog() in
a loop , the program dumps after 128 cycles...... , the problem aggravates in
later releases with the present gprolog-1.2.8 running only for 28
cycles. Is there a memory leak ?
Regards,
Mihir.