Multi-threading related questions including technique, structure, and safety issues.

learn more… | top users | synonyms (3)

15
votes
8answers
1k views

Plagued by multithreaded bugs

On my new team that I manage, the majority of our code is platform, TCP socket, and http networking code. All C++. Most of it originated from other developers that have left the team. The current ...
4
votes
2answers
2k views

Why would one ever want to use a synchronized method in Enum?

I stumbled upon this question and a couple of other along the same lines. While we know creation of enum is thread safe and enums are by birth singletons . It kind of confuses me that why would ...
1
vote
3answers
462 views

timers with threads on queue

So I've been asking the wrong questions for the last three days and after searching a lot I think I have an idea of what I need, my question is how to use timers with two threads writing and reading ...
3
votes
4answers
723 views

Testing thread safety

Say you have a function f that is or contains a critical section. How would you unit test that only one thread can run it at once, that it doesn't have race conditions, and that it doesn't cause a ...
1
vote
2answers
598 views

IPC in C under linux

I'm building a messaging solution with the followingsetup: all the messages are saved on a DB, two or more reader processes will read from this DB and send data to other process(es) which will send it ...
4
votes
1answer
610 views

Need to process 2 million 100k messages per second and route them to a particular event, delegate or multicast delegate

I need to process 2 million messages per second (perhaps in a scale out configuration) and route each message to a N delegates or multicast delegates. Question How should I structure my application ...
3
votes
1answer
1k views

How to read from a database, and write to a file asynchronously / non blocking way in Java

I'm trying to modify a serial program that reads from a database, and writes results to a file, this is done in a blocking way and I think we can get performance boost of there is a memory buffer and ...
1
vote
1answer
296 views

Sharing SCTP connection with multiple threads

I have an application that needs to run in SCTP environment, I have a question in sharing the connection among multiple threads for packet receiving only, I've tried with the sctp_sendmsg and it ...
1
vote
4answers
183 views

Resource/Thread Allocation and Deadlock

Here is the question I'm having trouble with: Give the resource graph and determine whether a deadlock state results. Assume that when a thread requests an available or unallocated resource, the ...
4
votes
5answers
310 views

What is the minumum code/operations to have in a separate thread?

I understand that threading is needed to get the maximum performance out of today's multicore processors but starting a thread is rather costly so you can't put every single calculation that can be ...
0
votes
1answer
246 views

Application that provides unique keys to multiple threads

Thanks all for your help before. So, this is what I came up with so far, the requirements are, application has two or more threads and each thread requires a unique session/transaction ID. is the ...
1
vote
3answers
115 views

Application that provides unique keys to multiple processes

Any idea on how to build an application that provides unique keys each time it get called by another process. Calling process isn't my problem here, my problem is how to sync between two(or more) ...
6
votes
4answers
634 views

Command-Query-Separation and multithreading safe interfaces

I like the command query separation pattern (from OOSC / Eiffel - basically you either return a value or you change the state of the class - but not both). This makes reasoning about the class easier ...
1
vote
2answers
260 views

Shared memory multiprocesses

I'm building an multi processes application and I need to save session ID, the sessions ID is 32 bit, and of course it can't be used twice in its lifetime, I'm currently using DB that saves all the ID ...
2
votes
1answer
833 views

C++ Multithreading on Unix

I have two related questions: Are there any good books for multithreading in C++, especially now that C++11 contains multithreading in the standard library? I have the Wrox Programming on Unix book ...
4
votes
4answers
427 views

If I use locks, can my algorithm still be lock-free?

A common definition of lock-free is that at least one process makes progress. 1 If I have a simple data structure such as a queue, protected by a lock, then one process can always make progress, as ...
1
vote
2answers
319 views

x86 segmentation and threading

Is some connection between using x86 segmentation and a possible implementation a thread package? I've been told that usually x86 segmentation is implemented in operating systems these days with an ...
2
votes
2answers
327 views

Is Multithreading Appropriate for Setting up Multiple Windows in the Same Application?

I am currently working with a Qt Application which tries to use multi threading to accomplish two task To Prevent the Main Thread's Event Loop from being blocked To increase computation efficiency ...
6
votes
4answers
4k views

Problems of multiple threads sharing/accessing the same data [closed]

I have been researching into when data is being accessed or shared by multiple threads within Java. And looking into the problems such as: Thread Interference Memory Consistency Deadlock Starvation ...
12
votes
3answers
2k views

What are the best resources for learning about concurrency and multi-threaded applications?

I realised I have a massive knowledge gap when it comes to multi-threaded applications and concurrent programming. I've covered some basics in the past, but most of it seems to be gone from my mind, ...
4
votes
3answers
2k views

Unit of work principle is causing a problem in MVC3 application

I am implementing a website using MVC3, Entity Framework 4.1 and Repositoty pattern, Unit of work principle. But I am facing a big problem while implementing this. I have developed a static ...
7
votes
2answers
2k views

Looking for a distributed locking pattern

I need to come up with a custom recursive object locking mechanism\pattern for a distributed system in C#. Essentially, I have a multi-node system. Each node has exclusive write permissions over ...
7
votes
2answers
311 views

where can I find an overview of known “multithreading systems architectures” design patterns? [closed]

Using C#, I have been doing multithreaded development for about 5 years, and consider myself quite proficient (I wrote my own lock-free queue and task parallel framework before Microsoft made TPF). ...
2
votes
3answers
448 views

Sharing buffer between multiple threads part 2

This is a follow up to my previous not answered question, so I try to make it more clear: last question. I have a n-size buffer that is filled up from an external source, it has 2 main methods get() ...
17
votes
2answers
517 views

Why does shared state degrade performance?

I've been working under the share-nothing principle of concurrent programming. Essentially, all my worker threads have immutable read-only copies of the same state which is never shared between them ...
4
votes
1answer
694 views

What's the current best practice for C multithreading?

I've been a Java (and PHP) developer for most of my life, but will need to use C for my next project. I remember some basic stuff we did back in school with fork, pthread, semaphores, etc. but I'm not ...
4
votes
2answers
922 views

How to parallelize a sequential algorithm?

What thought process should one follow to convert a sequential algorithm to a parallel one ? Are there any specific code pattern that can be parallelized. Some patterns that I normally use are: ...
4
votes
2answers
240 views

Decoupling Threads

It's not uncommon to hear of decoupling the UI from program logic, or database design/access from program logic...or even program logic from itself. However, I've never heard of an approach to ...
2
votes
5answers
3k views

Sharing buffer between multiple threads

I had a job process that was executing a lot of IO to read and write temporary files. Now I want to (need to) reduce the quantity of IO executions. So I want to create a sort of circular buffer ...
7
votes
9answers
2k views

Multithreaded file copy

There is an utility we have which is used to upload files (and perform other operations on the file) to a network shared location. The file size tends to vary from a few mb to 500 mb. A suggestion has ...
4
votes
1answer
404 views

Is there a formula to figure out the total execution time of sequential asyncronous processes?

I have a set of steps that need to run sequentially over a list of data. However each step only operates on a single piece of data at a time. Because of this, I can run the steps asynchronously. For ...
3
votes
1answer
239 views

What are the relative merits for implementing an Erlang-style “Continuation” pattern in C#

What are the relative merits (or demerits) for implementing an Erlang-style "Continuation" pattern in C#. I'm working on a project that has a large number of Lowest priority threads and I'm wondering ...
13
votes
3answers
6k views

UML Diagrams of Multi-Threaded Applications

For single-threaded applications I like to use class diagrams to get an overview of the architecture of that application. This type of diagram, however, hasn’t been very helpful when trying to ...
2
votes
1answer
171 views

Threading models when talking to hardware devices

When writing an interface to hardware over a communication bus, communications timing can sometimes be critical to the operation of a device. As such, it is common for developers to spin up new ...
16
votes
3answers
3k views

Why not Green Threads?

Whilst I know questions on this have been covered already (e.g. http://stackoverflow.com/questions/5713142/green-threads-vs-non-green-threads), I don't feel like I've got a satisfactory answer. The ...
3
votes
2answers
258 views

Massive vehicular network simulator

I am interested in making a vehicular network simulator (vehicular network as in vehicles can be equipped with radios and when they come in range they can talk with each other). I want to be able to ...
5
votes
2answers
1k views

How to do thread management in C++?

We use pthread for thread management in C based systems. pthread is in general compilable by C++ compiler (like g++). However, what are the better ways of abstractions for threads in C++? Also, for ...
4
votes
1answer
375 views

Producer-consumer pattern with consumer restrictions

I have a processing problem that I am thinking is a classic producer-consumer problem with the two added wrinkles that there may be a variable number of producers and there is the restriction that no ...
9
votes
2answers
571 views

Is my description of the actor model right?

If I understood, the actor model is just like the object model, but with a few differences: EVERY object spawns it's own separate thread and its not a problem even when you have thousands of ...
14
votes
3answers
6k views

How will C# 5 async support help UI thread synchronization issues?

I heard somewhere that C# 5 async-await will be so awesome that you will not have to worry about doing this: if (InvokeRequired) { BeginInvoke(...); return; } // do your stuff here It looks ...
6
votes
2answers
600 views

Thread class design?

I have a method like this in my UI code: void MyDialog::OnCommandSaveData() { std::list<MyClass*> objects; service_->GetAll(objects); dataService_->SaveObjects(objects); ...
11
votes
6answers
1k views

Solutions to C# 5 async re-entrancy

So, something's been bugging me about the new async support in C# 5: The user presses a button which starts an async operation. The call returns immediately and the message pump starts running again ...
5
votes
2answers
877 views

Is there such a thing as too much asynchronous code?

I am at the moment messing around with clients and servers in C# winforms and I'm trying to implement it all asynchronously. However, I'm beginning to wonder, should I use asynchronous code for ...
19
votes
10answers
5k views

State machines vs threads

Alan Cox once said "A Computer is a state machine. Threads are for people who can't program state machines". Since asking Alan directly is not an option for humble me, I'd rather ask here: how does ...
4
votes
2answers
366 views

Multithreaded Programming? [closed]

Recently I've finished learning about multithreaded programming on single shared objects, but was curious about how different things would be in order to successfully program on multiple shared ...
50
votes
14answers
5k views

How important is multithreading in the current software industry?

I have close to 3 years experience writing web applications in Java using MVC frameworks (like struts). I have never written multithreaded code till now though I have written code for major retail ...
2
votes
1answer
1k views

Common Qt Producer/Consumer Example: What is the point of multithreading here?

While trying to figure out how to implement a Producer/Consumer Queue in Qt, I stumpled upon several SO answers, blogs and sites linking to this site: You're doing it wrong... I got the point of ...
5
votes
1answer
5k views

THREADS: Kernel threads vs. Kernel-supported threads vs. User-level threads?

Does anyone know what the difference between these are? It seems to me that kernel threads correspond to the code that runs the kernel (intuitively), but I'm not sure about the other two... Also, ...
8
votes
9answers
8k views

Learning Multi-Threading Fast - C# [closed]

I received an offer for a job where approximately 80% of my work will be multi-threading related. My multi-threading experience is limited to my undergrad (UNIX programming course) and two instances ...
7
votes
5answers
233 views

When developing a piece of software, when do you start thinking/designing the concurrent sections?

Following along with the principle of not optimizing too early, I'm wondering at what point in the design / development of a piece of software do you start thinking about the concurrency ...