this is the standard approach to create locks using file system. For example, visudo uses it:
[ -f ".lock" ] && exit 1
touch .lock
# do something
rm .lock
1) I'm confused, for there's a race condition, yet Linux uses it
2) is there a better way to lock on files from shell?
3) or do I have to use directories instead?
Found solutio...
I am using a global named mutex for file access synchronization between an ASP.NET application and a console application.
While running the ASP.NET application, the console application fails to acquire mutex - as expected. While running the console application, the ASP.NET application throws UnauthorizedAccessException: Access to the pa...
How do i implement Mutex lock in Nant,
the reason why i need this feature is because
i register COM components in order to get my build working , and then end of the build
i Un Register the COM components.
without mutex lock, different version of COM are registered and face some issues.
so it would be better if we apply mutex lock i...
I am using xcode 2.4.1 on tiger. When i do below everything is ok. when i do
pthread_mutex_t mute;
ImageMan()
{
dibSize=0;
mute = PTHREAD_MUTEX_INITIALIZER;
}
I get these two errors
error: expected primary-expression before '{' token
error: expected `;' before '{' token
I dont know why. However if i do pthread_mutex_t mute = PT...
Hi!
Please take a look on the following pseudo-code:
boolean blocked[2];
int turn;
void P(int id) {
while(true) {
blocked[id] = true;
while(turn != id) {
while(blocked[1-id])
/* do nothing */;
turn = id;
}
/* critical ...
I've got a web application that controls which web applications get served traffic from our load balancer. The web application runs on each individual server.
It keeps track of the "in or out" state for each application in an object in the ASP.NET application state, and the object is serialized to a file on the disk whenever the state i...
If the locks make sure only one thread accesses the locked data at a time, then what controls access to the locking functions?
I thought that boost::mutex::scoped_lock should be at the beginning of each of my functions so the local variables don't get modified unexpectedly by another thread, is that correct? What if two threads are tryi...
How do i tell if one instance of my program is running?
i thought i could do this with a data file but it would just be messy :(
i want to do this as i only want 1 instance to ever be open at one point.
Edit: Re-tagged
...
Related to this question, what is the best practice for naming a mutex? I realize this may vary with OS and even with version (esp for Windows), so please specify platform in answering. My interest is in Win XP and Vista.
EDIT: I am motivated by curiousity, because in Rob Kennedy's comment under his (excellent) Answer to the above-lin...
Here's the thing: I have two applications, written in C++ and running on two machines with different OS (one Linux and one Windows). One of this process is in charge of updating an XML file on a NAS (Network Attached Storage) while the other one reads this file.
Is it possible to synchronize these two processes in order to avoid readin...
I was pondering language features and I was wondering if the following feature had been implemented in any languages.
A way of declaring that an object may only be accessed within a Mutex. SO for example in java you would only be able to access an object if it was in a synchrnoised block and in C# a Lock.
A compiler error would ensue i...
Hi,
I have a shared mutex between 2 applications.
I want to create an administration console that shows the current owner's name of the mutex.
How can I get the application name that currently owns the Mutex?
...
My iPhone client has a lot of involvement with asynchronous requests, a lot of the time consistently modifying static collections of dictionaries or arrays. As a result, it's common for me to see larger data structures which take longer to retrieve from a server with the following errors:
*** Terminating app due to uncaught exception 'N...
Now, I'm not sure whether this is a stupid question, please bear with me if it is.
Is the lock on an object "recursive", i. e. if two objects have references to a third object in their fields and a thread is running a synchronized method on one of the two, can any other thread access the third object?
// a and b are some objects that i...
Wouldn't this be overkill and only one of these necessary? I've searched and found different posts about Mutual Exclusion and locks in C# here and here.
Example:
In our app, we have a function that spins off multiple reconnection threads and inside this thread we use a Mutex and a lock. Wouldn't lock block access to this section of code ...
I'm using this code to prevent a second instance of my program from running at the same time, is it safe?
Mutex appSingleton = new System.Threading.Mutex(false, "WinSyncSingalInstanceMutx");
if (appSingleton.WaitOne(0, false)) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRender...
I have several threads that acquire Mutexes and then terminate.
The mutexes are stored in a main repository, and are properly released when the program exists. However, when the thread that allocated a Mutex exists, the mutex gets released automatically, and subsequent acquire AbandonedMutexException (also according to the documentation...
I have a Windows Forms application that allows only one instance to be running at the time. I have implemented Singleton by using Mutex. The Application must be startable from commandline (with or without parameters). Application is started and exited by script. User can not take any action on it.
So, application purpose is simple "indi...
I'm doing a simple ray tracer in C++ using SDL for graphics and pthread for threading. And I have a problem making my program utilizing two cores, the threads work, they just don't drive both cores to 100%. To interface SDL I write directly to it's memory, SDL_Surface.pixels, so I assume that it can't be SDL locking me.
My thread functi...
(I think that) the consensus number for a mutex is 2.
What is the consensus number for semaphores (like in pthread_sem_*)?
What is the consensus number for condition variables (like in pthread_cond_*)?
...