mutex

How to run the mutex code in c#.net on button click event?

This is my code which I had tried to run in my c# .net 3.5 program but I'm getting errors. What am I doing wrong? error CS0115: 'Form1.Dispose(bool)': no suitable method found to override This is the code where i got the error: protected override void Dispose(bool disposing) { if (disposing) { this._userConnectionO...

interlock vs mutex, scale-up issues

Hi, I am facing the problem, that I have an C# (.NET) object shared among some threads. A thread might replace the object with another one. The threads are waken up from a TCP/IP connection using the Asynchronous framework. Sequence: Threads (waiting for connection) -> Asynchronous Callback -> Do something thread-safe -> Access the sh...

.Net System Wide Flag to determine if Application/Thread is Running

I'm developing a long running process that hosts remoting objects. Due to design restrictions, I cannot use a Windows Service so the process is a background Forms application. I also cannot use WPF because we are restricted to .Net 2.0. In any case, since there is no guarantee that the background process is running, I want to be able to ...

Can I mix futex-based mutexes with glibc-2.2 linuxthreads mutexes?

Hello If you don't know what is futex and linuxthreads-0.9, please, don't reply. Can I mix in one program futex-based mutex with mutex from linuxthreads-0.8 or -0.9 (which was used in all glibc <=2.2 and in all uClibc) ? I need interprocess mutex (pshared one, PTHREAD_PROCESS_SHARED). So, If threads are started and managed by linuxth...

does a getter function need a mutex?

I've a class that is accessed from multiple threads. Both getter and setter functions are guarded with locks. Are the locks for getter functions relly needed? Why? class foo { public: void setCount (int count) { boost::lock_guard<boost::mutex> lg(mutex_); count_ = count; } int count () { boost::lock_...

bionic (andorid libc) mutex variants

Hello Which types of mutex does bionic libc support? recursive timed adaptive errorchecking ...

Use of Mutex between a c# exe and an c++ dll

Is it possible to use a Mutex Object for a application which users c++ dll to do background work and a c# to display it. Bot these use a common resource ie db . So can Mutex be used to lock this resource. In my db c++ will insert to db and c# will read it. ...

Creating named Mutex in c# exe and Accessing it a dll in c++

Hi All, I have two exe's one in C# and other is a vc++ exe . Both of these exe need to access a file. So I am planning to create a named mutex in c#. vc++ how can i access this named mutex. Can any one give me sample codes for this ...

How are condition varaibles implemnted?

This has baffled me for a long time. Given basic atomic primitives like compare & swap, I can see how to implement a spin lock (from which I can build mutexes). However, I don't see how to build condition variables out of this. How is this done? Thanks! ...

Looping threads accessing pthread mutex

Hey all im building this application in which i have a client represented by a thread, running in loop (until it receives the instruction to terminate) trying to access a critical section of data in the server. When the first client connects to the server, he owns the lock to that mutex. all the subsequent connections are put to a hold...

Mutex needed in MSMQ?

I'm browsing source codes from two applications sharing one queue using MSMQ. The first application has a thread that writes into the queue while the second application has another thread that reads from the queue. Ordinarily, if you're implementing your own queue, the applications would need a mutex when accessing the queue, right? Howe...

Non-recursive mutex ownership

I read this somewhere in SO: "recursive mutex has a sense of ownership, the thread that grabs the mutex must be the same thread that releases the mutex. For non-recursive mutexes, there is no sense of ownership and any thread can release the mutex no matter which thread originally locked the mutex." I'm confused by the last statement. C...

C#: How to prevent two instances of an application from doing the same thing at the same time?

If you have two threads within an application, and you don't want them to run a certain piece of code simultaneously, you can just put a lock around the piece of code, like this: lock (someObject) { // ... some code } But how do you do the same thing across separate processes? I thought this is what you use a "global mutex" for, s...

Lock, mutex, semaphore... what's the difference?

I've heard these words related to concurrent programming, but what's the difference between them? ...

Read write mutex in C++

This is an interview question. How do you implement a read/write mutex? There will be multiple threads reading and writing to a resource. I'm not sure how to go about it. If there's any information needed, please let me know. Update: I'm not sure if my statement above is valid/understandable. But what I really want to know is how do you...

suspend/resume task

Hi, I am asking question about multithreading in general. For example I locked a mutex and resume the task, then I want to suspend it, my question is, should I unlock the mutex before suspending it? So that when I resume it again with mutex it will resume successfully? I just got started in multithreaded stuff and I am having a hard ti...

synchronising threads with mutexes

In Qt, I have a method which contains a mutex lock and unlock. The problem is when the mutex is unlock it sometimes take long before the other thread gets the lock back. In other words it seems the same thread can get the lock back(method called in a loop) even though another thread is waiting for it. What can I do about this? One thre...

How can manage many user requests to an apache web server using win32com in python?

Hello every body, I work on a Web text-to-speech System, trasforming text documents in audio mp3 files, using python 2.5. I use Apache2.2 as a server and mod_python as module to embed the Python interpreter within the server. The user should submit via web interface (input interface), a file txt or a Word document (.doc or .rtf) and th...

PHP session handling when the same client requests the same script multiple times at once

So here's my test setup: session_start(); if(!isset($_SESSION['bahhhh'])) $_SESSION['bahhhh'] = 0; $_SESSION['bahhhh']++; sleep(5); die('a'.$_SESSION['bahhhh']); What I expect to happen is that each time I hit the page, it returns a different number. But if I use multiple tabs, and refresh them each within 5 seconds of the first, ...

How to connect signals into complex circuits in .NET?

For some concurrent code, I want to connect a bunch of signals together like a circuit. In .NET we can do a WaitAll or WaitAny on a collection of signals. I want to do something like this: WaitAny ( WaitAll (c1, c2), WaitAll (c3, c4) ) ; Unfortunately, the library doesn't support composing these operations into more complex trees. My ...