[mercury-users] announced: libtiff foreign interface (caveats)

Jonathan Morgan jonmmorgan at gmail.com
Thu Feb 8 20:45:56 AEDT 2007

On 2/7/07, Peter Wang <wangp at students.csse.unimelb.edu.au> wrote:
> On 2007-02-06, doug.auclair at logicaltypes.com <doug.auclair at logicaltypes.com> wrote:
> > Dear Julien and Jonathan:
> >
> > [...]
> > >>> are guarded by a [Melbourne] Mercury generated mutex, and thus
> > >>>are perfectly thread safe.
> >
> > Removed warning from README and source code comments [and I read
> > the relevant 'Foreign code attribute' section].
> The mutex only protects a single foreign_proc at a time.  It doesn't
> prevent two instances of read_to_matrix or write_as_tiff from executing
> at the same time, for example.  You'd need to get rid of the two globals
> in libtiff_io.c and pass them around as parameters.

Unless I misunderstand what you are saying, I wouldn't read the
reference manual that way at all.  For a start, I would certainly say
that the reference manual states that two copies of a foreign
procedure marked non_thread_safe cannot be executed at the same time.
In addition, I would say that the statement "All non-thread-safe
foreign language code shares a single mutex." means that not more than
one foreign procedure marked not thread safe can be executed at the
same time, making this code thread safe (though I would not think that
the general description of thread safety made this portable).

Please clarify this statement.

mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list