Mutex question

  • Thread starter Michael A. Covington
  • Start date
M

Michael A. Covington

What is the difference between

myMutex.WaitOne(n,false);

and

myMutex.WaitOne(n,true);

where n is a number of milliseconds and myMutex is a Mutex?

The second parameter supposedly says whether to "exit the synchronization
domain before waiting." What does that mean?

Also, can anyone tell me anything about naming of named mutexes? I
understand "Local\\" at the beginning of the name means something, but I
haven't found where this is documented.

Many thanks!

--

Michael A. Covington - Artificial Intelligence Ctr - University of Georgia

"In the core C# language it is simply not possible to have an uninitialized
variable, a 'dangling' pointer, or an expression that indexes an array
beyond its bounds. Whole categories of bugs that routinely plague C and C++
programs are thus eliminated." - A. Hejlsberg, The C# Programming Language
 
R

Richard A. Lowe

Hi Michael, as I understand it you would have to specify a synchronized
context via a SynchronizationAttribute (the one from
System.Runtime.Remoting.Contexts NOT EnterpriseServices) and a class derived
from ContextBoundObject for there to be any difference in behaviour with
this parameter. If you are using the latter, setting it to 'true' will
prevent deadlocks by allowing other threads into the context before you gain
the WaitSleepJoin state.

It's not perfectly clear to me, though, since I've never implemented it. I
doubt many will since .NET Contexts are not terribly well documented and
their uses not well understood (I include myself in that last statement as
well).

Other than the Mutex's name being global, I don't know of any special
behaviour vis-a-vis certain naming conventions so I can't help you there.

Richard
 
D

Dave

Other than the Mutex's name being global, I don't know of any special
behaviour vis-a-vis certain naming conventions so I can't help you there.

Naming a mutex allows it to be used for cross-process synchronization -
unnamed mutexes are only visible within the owning process. There are no
user-mode requirements or conventions regarding mutex names other then to
name them so they are unique otherwise you may inadvertently step on one
that is in use. The Win32 kernel mode device manager has some conventions it
follows when it creates them but it's been a while and I don't remember the
details and it's nothing that affects anything in user mode.
 
M

Michael A. Covington

Thanks.

Next question: Is there a debugging tool that will show me the operating
system's whole list of named mutexes and which process owns which one?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top