guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursive mutexes?


From: Neil Jerram
Subject: Re: Recursive mutexes?
Date: 27 Oct 2002 07:55:56 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Marius" == Marius Vollmer <address@hidden> writes:

    Marius> Neil Jerram <address@hidden> writes:
    >> 
    >> True, but a situation like this (the same thread trying to relock the
    >> same mutex) can alert you to a programming error.  A dramatic problem
    >> (the program hanging) is often more useful than the error being hidden.

    Marius> Yes.  But shouldn't a non-recursive mutex signal an error in this 
case?

Traditionally no - it just hangs.  But I can't think of a reason why
this behaviour is good, and why it wouldn't be better to signal an
error.

I'm not sure Thomas's point about traditional semantics is valid,
since mutexes are normally provided by relatively low-level interfaces
(e.g. POSIX, Win32) that don't support exceptions.

    Marius> What about having only one type of mutex but different kind of 
locking
    Marius> functions?  One for recursive locks and one for non-recursive error
    Marius> checking ones.  That seems mighty clean to me.

Sounds nice to me too.

    Marius> Such uses of a mutex are, in my view, a mockery of
    Marius> condition variables should be avoided.
    >> 
    >> I think you'll have to rephrase that! :-)

    Marius> Err, there's a "and" missing: "and should be avoided."

Some uses of this would be a mockery of condition variables, I agree.
But there are other possible uses, e.g. a program cleaning up before
exiting, that needs to do its thing even when other program threads
may have hung.  So, if the implementation is not too hard, I think we
should have this interface.

    Marius> Given what I have planned for our threads, we would need to 
implement
    Marius> our own mutexes anyway (using pthread mutexes, for example).  I 
would
    Marius> like to extent 'select' (with a new name) so that it can wait on IO
    Marius> and mutexes and condition variables and other stuff at the same 
time.

Win32 has this: `WaitForMultipleObjects'.  Can it be done in a POSIX
system without polling?

    Marius> This is something that you can build on top of the primitives, but I
    Marius> think we should offer rich tools that do a lot of useful things out 
of
    Marius> the box.

Totally.

        Neil





reply via email to

[Prev in Thread] Current Thread [Next in Thread]