How are mutexes implemented?
Are some implementations better than others for specific applications? Is there anything to earn by rolling out your own? ...
Are some implementations better than others for specific applications? Is there anything to earn by rolling out your own? ...
The Microsoft documentation is silent about what happens if I mistakenly call ReleaseMutex() when the mutex is already unlocked. Details: I'm trying to fix up some Windows code without having access to the compiler. I realise that WinApi mutexes are all recursive, and reference-counted. If I were making use of that feature, it's obvi...
I have an ISAPI filter that runs on IIS6 or 7. When there are multiple worker processes ("Web garden"), the filter will be loaded and run in each w3wp.exe. How can I efficiently allow the filter to log its activities in a single consolidated logfile? log messages from the different (concurrent) processes must not interfere with eac...
I have a class that has a state (a simple enum) and that is accessed from two threads. For changing state I use a mutex (boost::mutex). Is it safe to check the state (e.g. compare state_ == ESTABLISHED) or do I have to use the mutex in this case too? In other words do I need the mutex when I just want to read a variable which could be co...
I have a mutex that controls access to a single object from multiple threads. When a thread has finished the mutex is unlocked to allow order threads to operate on the object. On Windows using the WaitForSingleObject function is there an order that threads are signaled? I want the first thread that attempts to lock the mutex to now be al...
What is the Mutex and semaphore In c#? where we need to implement? How can we work with them in multithreading? ...
[EDIT NOTE: Noticed I had put the mutex creation in the constructor. Moved it and noticed no change.] [EDIT NOTE 2: I changed the call to app.exec in a trial run to while TRUE do app.processEvents() puts '." end I noticed that once the Soap4r service started running no process events ever got called again] [EDIT NOTE 3: Cr...
I have a base class, Token. It has no implementation and as such acts as a marker interface. This is the type that will be used by callers. { Token t = startJob(jobId); // ... (tasks) // t falls out of scope, destructors are called } I have a derived class, LockToken. It wraps around a mutex and insures the lock is acquire...
I am creating an application that implements inter process communication. For this purpose I have set up a shared buffer, which seems to work fine. Now, I need a way for the data generating application (written in c++) to tell the data receiving application (written in freepascal/lazarus) when it should read the data. I was trying to...
I read somewhere (can't find the page anymore) that lock free data structures are more efficient "for certain workloads" which seems to imply that sometimes they're actually slower or the gain from them can be zero in some situations. Taking the ~100 cycle hit of a lock instruction to do an atomic op sounds plenty faster to me than going...
I have a multithreaded C++ application which holds a complex data structure in memory (cached data). Everything is great while I just read the data. I can have as many threads as I want access the data. However the cached structure is not static. If the requested data item is not available it will be read from database and is then in...
Hi , I have a multi-R/W lock class that keeps the read, write and pending read , pending write counters. A mutex guards them from multiple threads. My question is Do we still need the counters to be declared as volatile so that the compiler won't screw it up while doing the optimization. Or does the compiler takes into account that t...
I am developing a class, which can be instantiated before main() is called. I have a critical sections protected by a mutex is the code. Unfortunately, the application fails on AIX as the code is called before threads are initialized. I want to add a check to the code to avoid mutex locking if threads are not ready and use the locking af...
Hi all, Back in my days as a BeOS programmer, I read this article by Benoit Schillings, describing how to create a "benaphore": a method of using atomic variable to enforce a critical section that avoids the need acquire/release a mutex in the common (no-contention) case. I thought that was rather clever, and it seems like you could ...
I have the following piece of code in thread A, which blocks using pthread_cond_wait() pthread_mutex_lock(&my_lock); if ( false == testCondition ) pthread_cond_wait(&my_wait,&my_lock); pthread_mutex_unlock(&my_lock); I have the following piece of code in thread B, which signals thread A pthread_mutex_lock(&my_lock...
I have read so many times, here and everywhere on the net, that mutexes are slower than critical section/semaphores/insert-your-preferred-synchronisation-method-here. but i have never seen any paper or study or whatever to back up this claim. so, where does this idea come from ? is it a myth or a reality ? are mutexes really slower ? ...
I have a desktop application that runs on a network and every instance connects to the same database. So, in this situation, how can I implement a mutex that works across all running instances that are connected to the same database? In other words, I don't wan't that two+ instances to run the same function at the same time. If one is...
Ok, I was running POV-Ray on all the demos, but POV's still single-threaded and wouldn't utilize more than one core. So, I started thinking about a solution in BASH. I wrote a general function that takes a list of commands and runs them in the designated number of sub-shells. This actually works but I don't like the way it handles acc...
Suppose a process is creating a mutex in shared memory and locking it and dumps core. Now in another process how do i ensure that mutex is already locked but not owned by any process? ...
Does pthreads support any method that allows you to query the number of times a recursive mutex has been locked? ...