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

Roy Ward rward at infoscience.otago.ac.nz
Tue Feb 5 12:37:52 AEDT 2002


Answering my own post here:

Roy Ward wrote:

> I'm about to explore getting OmniORB running in
> single-threaded mode ... 

It turns out that something based on this is one solution
(abeit an ugly hack).

I modified the server so that:
* all Mercury processing is handled in the main thread
* the Mercury setup is done before anything else,
* only one thing is running at once (I'm not 100% sure
that this part isn't flakey, but it is certainly only
processing one request at once).

It now seems to runs fine (although I'm stress testing
it now), and rather than post C++ code to a Mercury
mailing list, if anyone wants to see the recipe of
pthread and mutex calls that I'm using, let me know
and I'll reply with some source code (using omniORB 3.0.4)

Fergus Henderson wrote:

>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
>
>	EXTRA_CFLAGS = -DGC_USE_LD_WRAP
>
>to the file `Mmake.params' before installing Mercury,
>
Thank you very much for that - it'll give me another lead
to try if my current approach breaks down, and is probably
the better long term solution, but what I've done avoids me
having to recompile Mercury (and deal with Mercury
makefiles).

Cheers,
Roy Ward.


--------------------------------------------------------------------------
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