4,817 questions
412
votes
8
answers
146k
views
What is a good pattern for using a Global Mutex in C#?
The Mutex class is very misunderstood, and Global mutexes even more so.
What is good, safe pattern to use when creating Global mutexes?
One that will work
Regardless of the locale my machine is in
Is ...
20
votes
5
answers
14k
views
In a multi-threaded C++ app, do I need a mutex to protect a simple boolean?
I have a multi-threaded C++ app which does 3D rendering with the OpenSceneGraph library. I'm planning to kick off OSG's render loop as a separate thread using boost::threads, passing a data structure ...
6
votes
4
answers
12k
views
Why would WaitForSingleObject return WAIT_FAILED
MSDN says
If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError.
The code is:
HANDLE m_mutex_handle; /**< m_mutex_handle. The ...
217
votes
8
answers
144k
views
Recursive Lock (Mutex) vs Non-Recursive Lock (Mutex)
POSIX allows mutexes to be recursive. That means the same thread can lock the same mutex twice and won't deadlock. Of course it also needs to unlock it twice, otherwise no other thread can obtain the ...
6
votes
2
answers
2k
views
PHP 5.x syncronized file access (no database)
I'm mostly familiar with Java, C and C++ in which there are ways to control that only one thread is accessing a resource at any given time. Now I'm in search for something similar but in PHP 5.x.
To ...
0
votes
2
answers
1k
views
How can I implement java-like synchronization (monitors) using the Win32 API?
Each Java object (and its class) has an associated monitor. In pthread terms a Java monitor is equivalent to the combination of a reentrant mutex and a condition variable.
For locking, the Win32 API ...
128
votes
7
answers
100k
views
Are Mutexes needed in javascript?
I have seen this link: Implementing Mutual Exclusion in JavaScript.
On the other hand, I have read that there are no threads in javascript, but what exactly does that mean?
When events occur, where ...
3
votes
3
answers
974
views
Intra-process coordination in mod_perl under the worker MPM
I need to do some simple timezone calculation in mod_perl. DateTime isn't an option. What I need to do is easily accomplished by setting $ENV{TZ} and using localtime and POSIX::mktime, but under a ...
19
votes
8
answers
44k
views
What is Test-and-Set used for?
After reading the Test-and-Set Wikipedia entry, I am still left with the question "What would a Test-and-Set be used for?"
I realize that you can use it to implement Mutex (as described in wikipedia),...
30
votes
10
answers
36k
views
C++ Thread, shared data
I have an application where 2 threads are running... Is there any certanty that when I change a global variable from one thread, the other will notice this change?
I don't have any syncronization or ...
0
votes
1
answer
2k
views
Why do I need to SEM_PRIORITY_Q when using a VxWorks inversion safe mutex?
In VxWorks, I am creating a mutex with the SEM_INVERSION_SAFE option, to protect against the priority inversion problem.
The manual says that I must also use the SEM_PRIORITY_Q option. Why is that?
5
votes
5
answers
2k
views
How to manage concurrent Input/Output access to a XML file from multiple instances of an EXE, using Delphi.
I have a command line tool, written in Delphi, which job is to insert a node in a XML file and then immediately exit. I need to make it possible several instances of the tool to be executed ...
1020
votes
37
answers
701k
views
Difference between binary semaphore and mutex
Is there any difference between a binary semaphore and mutex or are they essentially the same?
9
votes
2
answers
4k
views
Is this the proper use of a mutex?
I have a situation where I might have multiple instances of a program running at once, and it's important that just one specific function not be executing in more than one of these instances at once.
...
1033
votes
10
answers
534k
views
What is a mutex?
A mutex is a programming concept that is frequently used to solve multi-threading problems. My question to the community:
What is a mutex and how do you use it?
744
votes
40
answers
268k
views
What is the correct way to create a single-instance WPF application?
Using C# and WPF under .NET (rather than Windows Forms or console), what is the correct way to create an application that can only be run as a single instance?
I know it has something to do with some ...
28
votes
3
answers
10k
views
How to use a mutex in Visual Basic
I have imported the kernel32 library. So, I have the createMutex function available but I am not quite sure of the various parameters and return values.
This is classic Visual Basic, not Visual Basic....