multithreading

Are partially updated values when multithreading still a concern on modern CPUs?

From the Wikipedia article on Read-Copy-Update: The reason that it is safe to run the removal phase concurrently with readers is the semantics of modern CPUs guarantee that readers will see either the old or the new version of the data structure rather than a partially updated reference. Is this true for all modern CPUs (ARM, x86, ...

Load multiple copies of dll in same process

I have a dll produced by a third party that has some sort of internal datastructure that limits it's size to X elements. So basically, it has a Queue with X as the limit. Now from what I've known DLL's are per process, but is it possible to load a DLL more than once? Maybe per thread? In C#? or in C++/CLI? I'm trying to load a native ...

MutliThread or Multi Lists?

hi, as i seen topic which not recommending more thn 200 threads for server machine, i am trying to implement Listener class which listens 1000 devices, i mean 1000 devices sending different type of messages to that application, i tried 2 different way 1. creat thread for each device runtime and dynamic list which hold the messages for...

Bad Fairness with a ReadWriteLock / SharedLock under load

Hello, we are currently designing a multithreaded server application. To optimize performance, we decided to implement a ReadWriteLock, i.e. multiple threads can get a lock if they only want to read but just one thread may hold the write lock. This lock is used with a list and iterating over the list is the "read" operation. Now this...

Multithreading in .NET - implementing a counter in the background

As a training exercise, I am creating a counter that runs in a background thread, in a .NET 3.5 WPF app. The idea is that the counter gets incremented and every few seconds the total is output to the screen. As it is a training exercise, the foreground thread doesn't really do anything, but imagine that it does! There is a start and s...

what is a relocatable executable and why it is needed

What is the use of relocatable executable and how is it generated and how it is used ? what do we mean by processes memory map remapping ? if some can explain me w.r.to embedded systems , it will be great thanks in advance -Das ...

Can I define frequency check for ThreadPool.QueueUserWorkItem?

I implemented a System.Web.IHttpAsyncHandler to limit website bandwidth usage for files download. Once defined user bandwidth, I need to send a byte[] every second (or 1000 milliseconds, to be precise). Something like: public class DownloadHandler : IHttpAsyncHandler { public IAsyncResult BeginProcessRequest( HttpContext con...

From PHP workers to Python threads

Right now I'm running 50 PHP (in CLI mode) individual workers (processes) per machine that are waiting to receive their workload (job). For example, the job of resizing an image. In workload they receive the image (binary data) and the desired size. The worker does it's work and returns the resized image back. Then it waits for more jobs...

Signal and Slot vs Multithreading in Boost Library

I have gone through similar questions on Stackoverflow but still can't get a good answer: how boost implements signals and slots How signal and slots are implemented I am quite puzzled on how this signal/slot is achieved. Q1: From the following code, sig is connected to two function(Hello() and World()), and it seems that the funct...

Parallel, but slower

I'm using monte carlo method to calculate pi and do a basic experience with parallel programming and openmp the problem is that when i use 1 thread, x iterations, always runs faster than n thread, x iterations. Can anyone tell me why? For example the code runs like this "a.out 1 1000000", where 1 is threads and 1000000 the iterations ...

When is messaging (e.g. JMS) an alternative for multithreading ?

I work on a data processing application in which concurrency is achieved by putting several units of work on a message queue that multiple instances of a message driven bean (MDB) listen to. Other then achieving concurrency in this manner, we do not have any specific reason to use the messaging infrastructure and MDBs. This led me to th...

Locking hierarchy of objects in .NET

I have a class that represents the "state of the world". The class has many collections of many other objects which in turn have references to more objects and collections of objects, sometimes even references to their ancestors in the "world hierarchy". To simplify what's being said, here is an example (transformed into XML, details omi...

Accessing .NET dictionary in a multithreaded environment.

Dear ladies and sirs. I would like to emply the if-lock-if pattern for checking if an object is present in the dictionary in a multithreaded environment. So, the code I am considering looks like so: private IDictionary<string, SomeType> m_dic = new Dictionary<string, SomeType>(); private SomeType GetSomeObject(string key) { SomeType...

Problem with Twisted and threads

Some of you that are more experienced using Twisted will probably judge me about using it together with threads - but I did it :). And now I am in somehow of a trouble - I am having an application server that listens for client requests and each time a new client connects it spawns another thread that I probably forget to properly close,...

How to manage a dictionary of lazily created objects in a multithreaded environment in .NET?

Dear ladies and sirs. This question is in continuation of this one. The deal is simple. Given: A collection of lazily created singletons. Multithreaded environment. Wanted: An implementation with as little lock penalty as possible when an already created object is accessed. It is OK to pay higher penalty on removal or lazy initia...

Boost interrupt in naive polling implementation

I have a developed a simple polling thread (using Boost 1.39.0) which checks whether a data resource has been accessed within a given timeframe and clears the connection if not. The relevant code can be reviewed below. My concerns are twofold: 1) Is using interrupt on a sleep appropriate to close down the thread safely? Will the interr...

Is std::string thead-safe with gcc 4.3?

I'm developing a multithreaded program running on Linux (compiled with G++ 4.3) and if you search around for a bit you find a lot of scary stories about std::string not being thread-safe with GCC. This is supposedly due to the fact that internally it uses copy-on-write which wreaks havoc with tools like Helgrind. I've made a small progr...

Waiting for mouse input in Java Swing

I'm working on a Java Swing application. I have a button whose action runs a query on a database and then plots the results. These commands are performed from the listener on the Run button. As I understand it, this means that the thread running at this point is from the EventQueue. Given certain input, I need to halt processing an...

calling concurrently Graphics.Draw and new Bitmap from memory in thread take long time

Example1 public partial class Form1 : Form { public Form1() { InitializeComponent(); pro = new Thread(new ThreadStart(Producer)); con = new Thread(new ThreadStart(Consumer)); } private AutoResetEvent m_DataAvailableEvent = new AutoResetEvent(false); Queue<Bitmap> queue = new Queue<Bitmap>(); ...

Threading in a PyQt application: Use Qt threads or Python threads?

I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot be split into smaller parts). This is why I'd like to outsource the web connection to a separate worker thread. [Yes, I know, now I have t...