[mercury-users] Calling Mercury code from a threaded enviromnent?

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Feb 4 17:00:58 AEDT 2002

On 04-Feb-2002, Roy Ward <rward at infoscience.otago.ac.nz> wrote:
> I've had a local expert looking at this, and he thinks
> that the problem is that the Boehm-GC is not set
> up to put wrappers around the pthread_create calls,
> so the Garbage Collection gets confused by not knowing
> about all the threads.

He might be right.  If so, approach "3b" described in
boehm_gc/doc/README.linux is probably the solution:

 | 3b) A new alternative to (3a) is to build the collector and compile GC
 |    clients with -DGC_USE_LD_WRAP, and to link the final program with
 |   ...
 |    (for gcc) -Wl,--wrap -Wl,read -Wl,--wrap -Wl,dlopen -Wl,--wrap \
 |              -Wl,pthread_create -Wl,--wrap -Wl,pthread_join -Wl,--wrap \
 |              -Wl,pthread_detach -Wl,--wrap -Wl,pthread_sigmask \
 |              -Wl,--wrap -Wl,sleep

For Mercury, this would mean adding


to the file `Mmake.params' before installing Mercury,
and arranging for those flags listed above to be passed to gcc when linking
the final executable.  If your main program is written in Mercury, adding

	EXTRA_MLFLAGS = -Wl,--wrap -Wl,read -Wl,--wrap -Wl,dlopen -Wl,--wrap \
	 -Wl,pthread_create -Wl,--wrap -Wl,pthread_join -Wl,--wrap \
	 -Wl,pthread_detach -Wl,--wrap -Wl,pthread_sigmask \
	 -Wl,--wrap -Wl,sleep

to your Mmakefile would do the trick.

If that solves the problem, please let us know.

Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe

More information about the users mailing list