slloyd has asked for the wisdom of the Perl Monks concerning the following question:

Is it possible to list all Mutexes currently open? Win32::Mutex allows me to create a Mutex, I am looking for a way to list existing Mutexes. Any ideas? Steve

-------------------------------
Need a good Perl friendly Host Provider?
http://www.dreamhost.com

Replies are listed 'Best First'.
Re: List Mutexes on Win32
by ikegami (Patriarch) on Feb 05, 2007 at 20:05 UTC
    I don't know how — I've searched and I will search some more — but it's possible because Microsoft's (formerly Sysinternal's) Process Explorer can list them. (They're listed as "Mutants" for some reason.) If it's just for debugging, maybe that tool will help you.
Re: List Mutexes on Win32
by BrowserUk (Patriarch) on Feb 05, 2007 at 20:34 UTC
    Is it possible to list all Mutexes currently open?

    Do you mean

    • for the current process that you've explicitly opened within your own code?
    • for the current process including those opened by perl's internals and modules you've called or libraries you are linked to?
    • all the mutexes in the system that you might want to open a handle to?

    All three are possible, but doing so requires the use of some fairly complex and obscure 'debugging' APIs. From memory, it also means using some officially 'undocumented' APIs--though my memory could be wrong on that.

    It's also the case that, other than for the purposes of debugging, it is usually not necessary to generate a list of existing Mutexes, so if you were to describe why you want to do this, there may be a simpler way of achieving your goal.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      It just occured to me that a DOS application that allowed me to view mutexes and semaphores might be a quicker way to debug than using Process Explorer from sysinternals. I believe they use an undocumented API called HandleEx.

      -------------------------------
      Need a good Perl friendly Host Provider?
      http://www.dreamhost.com

        Hmm. The other tool around that can do this is SysInternals HandleEx. This apparently requires a custom (and non-open source) device driver to achieve it.

        I'm positive I saw some sample code showing how to do this whilst searching for something else a coupe of years ago, but I cannot find it now.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.