[m-rev.] for review: avoid deadlock in tabled_read_unitize test
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Aug 29 15:52:13 AEST 2002
On 28-Aug-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> we should change the compiler to check for this. A foreign_proc with a
> unitize annotation should have either
>
> - a thread_safe annotation, or
> - a new annotation asserting that the callbacks to Mercury will not call any
> non-thread-safe foreign_procs.
>
> This check would be needed only in .par grades, of course.
Two comments:
(1) This should apply to all foreign_procs with `may_call_mercury'
annotations, not just those with `tabled_for_io_unitize' annotations.
(2) A better solution to the problem would be to use a recursive mutex,
i.e. one in which a thread is allowed to reacquire a mutex that it
already holds, for the global lock.
Recursive mutexes can be implemented using PTHREAD_MUTEX_RECURSIVE,
which is part of the Unix 98 and POSIX 2001 standards. It would
also be possible to implement recursive mutexes on top of ordinary
mutexes, for systems which don't support Unix 98 / POSIX 2001,
but I don't know whether this is worth the effort.
--
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-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list