473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Mutex question

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
Nov 15 '05 #1
5 1886
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

--
C#, .NET and (a bit of) Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address> wrote
in message news:O9*************@tk2msftngp13.phx.gbl...
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

Nov 15 '05 #2
> 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.
Nov 15 '05 #3
The Local\ and Global\ prefixes are used to determine the scope of the name
when used in Terminal Services sessions. Local\ creates an object that is
valid in that session only and Global\ creates an object visible in all
sessions. Check out:

http://msdn.microsoft.com/library/de...namespaces.asp
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address> wrote
in message news:O9*************@tk2msftngp13.phx.gbl...
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

Nov 15 '05 #4
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?
Nov 15 '05 #5
"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address> wrote
in news:#l**************@tk2msftngp13.phx.gbl:
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?


try www.sysinternals.com - likely something there.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
3
by: smith4894 | last post by:
Hello, I have an application that essentially consists of two threads doing their things. One thread is a producer, and pushes bytes (of a struct) into a pipe, and another is a consumer that...
16
by: Ed Sutton | last post by:
I use a mutex to disallow starting a second application instance. This did not work in a release build until I made it static member of my MainForm class. In a debug build, first instance got...
2
by: William LaMartin | last post by:
I posted this in the ASP.net newsgroup with no response, so I will try it here: What needs to be changes to make this work? It is on a Windows 2003 shared server. This code: Private...
6
by: Jun Kusanagi | last post by:
Is there any way to solve process synchronization between more than 1 resources. I'm already trying to use Mutex.WaitAny, but I confused to execute Release method from the corresponding mutexes....
2
by: tony.newsgrps | last post by:
Hi there, I'm trying to understand the impact of killing a process that owns a system mutex (used to ensure there is only 1 instance of my program running) Here is my code pretty much: try...
8
by: Dan Pavel | last post by:
Hi, I did not used Mutex before and I need now. I have an application that control some workflows on different machines. I use SNMP for that. The problem is that the thread used for starting an...
1
by: chsalvia | last post by:
I was browsing through the souce code for the boost mutex implementation just to understand how the library works. I get the basic idea: a mutex object is associated with a scoped_lock object....
2
by: Jeroen | last post by:
Hi all, I've been trying to get my head around threading. Here's an example from the book I'm reading: /***************************/ Mutex m = null; const string name = "xyz"; try
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.