multithreading

Differences between Conditional variables, Mutexes and Locks

For example the c++0x interfaces I am having a hard time figuring out when to use which of these things (cv, mutex and lock). Can anyone please explain or point to a resource? thanks in regard ...

How to avoid deadlocks?

When using multiple threads, shared memory needs to be locked by critical sections. However, using critical sections causes potential deadlocks. How can they be avoided? ...

thread is stuck while registering channel with selector in Java NIO server.

I have a basic question. Why and how SelectableChannel's register method can be in blocking call. Let me provide a scenario. I have created a Selector object in class Register as follows. private static Selector selector = Selector.open(); I also have a method in same class(Register) to register the channel with the selector. ...

How to avoid mutable state (when multithreading)

Multithreading is hard. The only this you can do is program very carefully and follow good advice. One great advice I got from the answers on this forum is to avoid mutable state. I understand this is even enforced in the Erlang language. However, I fail to see how this can be done without a severe performance hit and huge amounts of cac...

Legacy VB6 COM+ DLL calling into native Win32 DLL -- threading issues with STA?

Hi all, Come across what looks at first sight like an MT-issue, but I'm trying to understand in detail the STA model used by COM+. Effectively, I have a legacy COM+ component, written in VB6, that calls into a native (i.e., not-COM) Win32 DLL written in C++. Having some intermittant (and impossible to reproduce in testing) problems wi...

What is saved in a context switch?

What is exactly saved and restored in a context switch between two threads in the same process between two processes ...

Force a Different Thread to Sleep

So I have a program that serves as a sort of 'shell' for other programs. At its core, it gets passed a class, a method name, and some args, and handles the execution of the function, with the idea of allowing other programmers to basically schedule their processes to run on this shell service. Everything works fine except for one issue...

What's the difference between using the thread pool and a normal thread?

I Was reading random questions and answers here on SO and came across this question: C#, IAsyncResult and the thread pool The question is asked is X method using the thread pool or using normal threads. What's the difference between using the thread pool and a normal thread? ...

InvalidOperationException - object is currently in use elsewhere - red cross

Hello I have a C# desktop application in which one thread that I create continously gets an image from a source(it's a digital camera actually) and puts it on a panel(panel.Image = img) in the GUI(which must be another thread as it is the code-behind of a control. The application works but on some machines I get the following error...

Locking a self-loading cache

I'm implementing a simple cache in C#, and trying to make it accessible from multiple threads. In the basic read case, it's easy: var cacheA = new Dictionary<int, MyObj>(); // Populated in constructor public MyObj GetCachedObjA(int key) { return cacheA[key]; } This is, I believe, completely thread-safe. But I'd also like to make ...

WPF, BitmapFrames & cross-threading question

Hello, I have some BitmapFrames created on a thread other than the main UI thread; Sometime after they are created (and their creator thread finishes), I am trying to use them in the main thread, as sources to some Image controls. BUT I am getting this InvalidOperationException: The calling thread cannot access this object because a...

Locking and multi threading in dotNet

I have multiple threads who all need to write to the same Dictionary. I have a lock on an object that I maintain in order to make sure only 1 thread is updating the dictionary at once. My question is as follows. If one thread tries to update the dictionary while another has a lock, will the thread just know to wait? Will it just fail? If...

C++ master/worker

I am looking for a cross-platform C++ master/worker library or work queue library. The general idea is that my application would create some sort of Task or Work objects, pass them to the work master or work queue, which would in turn execute the work in separate threads or processes. To provide a bit of context, the application is a C...

Are multithreaded apps bound to a single core?

Hi, I'm running a .NET remoting application built using .NET 2.0. It is a console app, although I removed the [STAThread] on Main. The TCP channel I'm using uses a ThreadPool in the background. I've been reported that when running on a dual core box, under heay load, the application never uses more than 50% of the CPU (although I've s...

Reality Question : Do you tune the IIS Max thread pool ??

By default, the IIS 6.0 process creates as many as four threads per processor. We can adjust the maximum number of threads in the IIS 6.0 service process by adding the MaxPoolThreads entry to the following registry path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Inetinfo\Parameters and give the value between 2 - 20. I would...

Transactions - A scenario

I have a subscriber on a bus to NewDeriative messages, which is flat and primitive DTO style, for example sake has three strings ModelName, ManufacturerName, DerivativeName. Inside the system there is a domain model of Manufacturer, Model and Derivative, a derivative has a Model, and a model has a Manufacturer. E.g. BMW --> X5 --> Sport...

Defalult no of Thread in Process in Asp.net 3.5

how many number of thread per process default in the system.thread.threadpool in asp.net 3.5 ? ...

SetCurrentDirectory in multi-threaded aplication

I understand SetCurrentDirectory shouldn't be used in a multithreaded application since the current directory is shared between all threads in the process. What is the best approach to setting the directory with this in mind. It can mostly be avoided setting the directory by including the full pathname when opening files instead of firs...

ThreadStart.BeginInvoke throws NotSupportedException on Compact framework

I'm working with threads on a compact framework project and have code that looks something like below. When I try to step into StartThreads(), a NotSupportedException is thrown. This seems a bit wierd, why is the exception thrown on the line calling StartThreads() and not inside, and what is it that's not supported on CF? I think its Thr...

Select() not Working in thread

Hi all, I have to monitor a serial port and process its data. As a test program I was using select for just one port. The run function is as follows: void <ProtocolClass>::run() { int fd = mPort->GetFileDescriptor(); fd_set readfs; int maxfd=1; int res; FD_ZERO(&readfs); FD_SET(fd,&readfs); struct timeval Ti...