[mercury-users] Style, Newbie decision question, "What? No X?!", Microbenchmark

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 21 03:32:25 AEDT 2002


On 20-Nov-2002, Julian Fondren <cleverjulian at hotmail.com> wrote:
> [Fergus wrote:]
> >the extras/concurrency library is implemented in different
> >ways, depending on which back-end and grade of the Mercury compiler you 
> >use:
> >
> >	(a) for the low-level back-end, Mercury threads are mapped to
> >	    "contexts" (the Mercury implementation's name for our lightweight
> >	    user-level threads), which can be scheduled either
> >	    (i) using non-preemptive scheduling (the asm_fast.gc grade) or
> >	    (ii) by multiplexing contexts over several Posix threads
> >	         (the asm_fast.gc.par grade), which will then execute
> >		 using the operating system's preemptive scheduling;
> >		 threads may thus run in parallel on multi-CPU machines
> 
> Oh, nifty.
>
> >	(b) for the high-level back-end, each Mercury thread is mapped to
> >	    to its own Posix thread (the hlc.gc.par grade)
>
> Thanks for the warning, I'll try to avoid this grade until it matures.
> (Or is the use of Posix threads a fundamental limitation?)

This one is a feature, not a bug! ;-)

The mapping of Mercury threads to Posix threads is a quite deliberate
design decision, based on the general approach in the high-level back-end
of mapping Mercury features directly onto the corresponding features in
the target language (in this case C).

This approach makes interoperability with other languages easier.
For example, with the hlc.gc.par grade, you can write inline C code
which uses thread-local storage (allocated either using the pthread
routines for thread-local storage, or GNU C's new `__thread' qualifier),
and be guaranteed that there will be one copy of this for each Mercury
thread.

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