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

learn more… | top users | synonyms (5)

5
votes
1answer
1k views

Many Blocking VS Single Non-Blocking Workers

Assume there is an HTTP server which accepts connections and then it has somehow wait for headers to be fully sent in. I wonder what is the most common way of implementing it and what are the rest ...
5
votes
1answer
7k views

How to program thread allocation on multicore processors?

I would like to experiment with threads on a multi-core processor, e.g. to create a program that uses two different threads that are executed by two different processor cores. However, it is not ...
16
votes
3answers
5k views

Why is multithreading often preferred for improving performance?

I have a question, it's about why programmers seems to love concurrency and multi-threaded programs in general. I'm considering 2 main approaches here: an async approach basically based on signals, ...
5
votes
4answers
431 views

What is thread safety? [closed]

What is it? I was reading Effective STL and came across it. I have also Googled it, but couldn't get any helpful info.
1
vote
1answer
469 views

How to create a Request Specific Thread Safe Static int Counter?

In one of my server application I have a class that look like, class A { static int _value = 0; void DoSomething() { // a request start here _value = 0; _value++; ...
7
votes
4answers
3k views

Difference between Atomic Operation and Thread Safety?

From the discussion I've seen it seems that atomic operation and thread safety are the same thing, but a lot of people say that they're different. Can anyone tell me the difference if there is one?
0
votes
1answer
616 views

Relationship between “Task Parallel Library” and “Task-based Asynchronous Pattern”?

In the context of C#, .NET 4/4.5 used for an application running on a web-server, what is the relationship between "Task Parallel Library" and "Task-based Asynchronous Pattern"? I understand one is ...
4
votes
2answers
365 views

Help me understand a part of Java Language Specification

I'm reading part 17.2.1 of Java language specification: http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.2.1 I won't copy a text, it's too long, but I would like to know, why for ...
1
vote
2answers
212 views

Requiring multithreading/concurrency for implementation of scripting language

Here's the deal: I'm looking at designing my own scripting/interpreted language for fun. I'm only in the planning stages right now; I want to make sure I have a very strong hold on exactly how I will ...
11
votes
7answers
1k views

Can you explain me why multiple threading need lock?

Assume these threads run in single core cpu. As a cpu only run one instruction in one cycle. That is said, even thought they share the cpu resource. but the computer ensure that one time one ...
1
vote
3answers
331 views

Inter-process and inter-thread data sharing [closed]

I know that operating systems facilitate inter-process and inter-thread data sharing. I want to know about the mechanisms used to facilitate such sharing. I read about "pipes". What are the other ...
15
votes
3answers
10k views

What is a thread pool?

In an interview question a guy was asked to "implement a threadpool"... I've been reading on wikipedia for "threadpool" but I still can't figure out what should a guy do to solve this question ...
0
votes
1answer
236 views

Is there a limit on the number of threads that can be spawned simultaneously?

Yesterday I came across this question: How can i call robocopy within a python script to bulk copy multiple folders?, and I though it might be a good exercise for multithreading. I though of spawning ...
24
votes
5answers
2k views

Does immutability entirely eliminate the need for locks in multi-processor programming?

Part 1 Clearly Immutability minimizes the need for locks in multi-processor programming, but does it eliminate that need, or are there instances where immutability alone is not enough? It seems to ...
1
vote
2answers
1k views

Synchronous sockets with Node.js

I want to port an existing app from Java to Node.js - would like to seek your advise. The java app is a multithreaded socket server where arbitrary number of clients can connect. The app runs on java ...
3
votes
2answers
701 views

What is the difference of delegator and dispatcher?

What is the difference of delegator and dispatcher? I am not quite sure of either concept.
3
votes
2answers
463 views

I have data that sends in “bursts” of 100 records with a significant delay. How do I structure my classes for multithreading?

My datasource sends information in 100 batches of 100 records with a delay of 1 to 3 seconds between batches. I would like to start processing data as soon as it's received, but I'm not sure how to ...
4
votes
1answer
921 views

Best Creational Pattern for loggers in a multi-threaded system?

This is a follow up question on my past questions : Concurrency pattern of logger in multithreaded application As suggested by others, I am putting this question separately. As the learning from ...
7
votes
2answers
529 views

Concurrency pattern of logger in multithreaded application

The context: We are working on a multi-threaded (Linux-C) application that follows a pipeline model. Each module has a private thread and encapsulated objects which do processing of data; and each ...
15
votes
8answers
17k views

Multithreading synchronization interview question: Find n words given m threads

I came across this question: You are given a paragraph , which contain n number of words, you are given m threads. What you need to do is , each thread should print one word and give the ...
7
votes
3answers
1k views

Naming Convention for Dedicated Thread Locking objects

A relatively minor question, but I haven't been able to find official documentation or even blog opinion/discussions on it. Simply put: when I have a private object whose sole purpose is to serve for ...
3
votes
3answers
476 views

Internal Mutation of Persistent Data Structures

To clarify, when I mean use the terms persistent and immutable on a data structure, I mean that: The state of the data structure remains unchanged for its lifetime. It always holds the same data, ...
-1
votes
1answer
1k views

What happens at control invoke function?

A question about form controls invoke function. Control1 is created on thread1. If you want to update something in Control1 from thread2 you must do something like: delegate void ...
2
votes
1answer
462 views

What is the best way to diagrammatically represent a system threading architecture?

I am yet to find the perfect way to diagrammatically represent the overall threading architecture for a system (using UML or otherwise). I am after a diagramming technique that would show all the ...
3
votes
2answers
639 views

Thread safe GUI programming

I have been programming Java with swing for a couple of years now, and always accepted that GUI interactions had to happen on the Event Dispatch Thread. I recently started to use GTK+ for C ...
2
votes
4answers
3k views

.NET mulithreading and quad core processors

I have a single threaded application that runs on a machine with a quad core processor. The scheduled tasks that run VB.NET forms are too slow. I am new to multi threading and parallel computing. ...
2
votes
1answer
150 views

Confusion related to sigwait in multiprocess system

I am having difficulty in understanding IPC in multiprocess system. I have this system where there are three child processes that send two types of signals to their process group. There are four types ...
3
votes
3answers
2k views

Is the singleton pattern prone to thread safety problems?

Is the singleton pattern prone to thread safety problems? If so, what are the best methods to work around them?
2
votes
4answers
449 views

When creating a library for a simple program, what must I do to protect others from its lack of thread safety?

When creating a library for a simple program, is it more cost effective to make it thread safe or is there a way to detect the program's use in a multithreaded program and ASSERT() or otherwise ...
4
votes
1answer
414 views

Reading and conditionally updating N rows, where N > 100,000 for DNA Sequence processing

I have a proof of concept application that uses Azure tables to associate DNA sequences to "something". Table 1 is the master table. It uniquely lists every DNA sequence. The PK is a load balanced ...
3
votes
1answer
188 views

Parallel Threading in Multi-Language Software?

I'm developing a software that contain many modules/Daemon running in parallel manner, what i'm looking for is how to implement that, i cannot use Thread because some of those modules/Daemon are ...
5
votes
4answers
3k views

What is a zombie process or thread?

What is a zombie process or thread, and what creates them? Do I just kill them, or can I do something to get diagnostics about how they died?
2
votes
2answers
734 views

Shared FIFO file descriptor

is ok to open fifo with one FD and share it with multiple threads? or is it better to have multiple fds opened for the same fifo and share these fds with the threads? BTW, I'll be doing write and ...
2
votes
2answers
624 views

Issues with time slicing

I was trying to see the effect of time slicing, and how it can consume significant amount of time. Actually, I was trying to divide a certain task into a number of threads and see the effect. I ...
3
votes
2answers
327 views

Is a 1:* write:read thread system safe?

Theoretically, thread-safe code should fix race conditions. Race conditions, as I understand it, occur because two threads attempt to write to the same location at the same time. However, what about ...
2
votes
1answer
745 views

Can I implement the readers and writers algorithm in OpenMP by replacing counting semaphores with another feature?

After reading about OpenMP and not finding functions to support semaphores, I did an internet search for OpenMP and the readers and writers problem, but found no suitable matches. Is there a general ...
48
votes
16answers
3k views

Should I take care of race conditions which almost certainly has no chance of occuring?

Let's consider something like a GUI application where main thread is updating the UI almost instantaneously, and some other thread is polling data over the network or something that is guaranteed to ...
2
votes
4answers
788 views

Should I build a multi-threaded system that handles events from a game and sorts them, independently, into different threads based on priority?

Can I build a multi-threaded system that handles events from a game and sorts them, independently, into different threads based on priority, and is it a good idea? Here's more info: I am about to ...
33
votes
7answers
3k views

Are there deprecated practices for multithread and multiprocessor programming that I should no longer use?

In the early days of FORTRAN and BASIC, essentially all programs were written with GOTO statements. The result was spaghetti code and the solution was structured programming. Similarly, pointers can ...
3
votes
5answers
285 views

What tool sets and applications have affinity with multiprocessor programming? [closed]

In grad school I took a class in multiprocessor and distributed operating systems. I think multiprocessor software development will become increasingly important and will be driven by the need to ...
3
votes
3answers
311 views

Analogy for Thread Pools

I am working on an application which spawns a new thread per request. Sometimes the number of threads active on the machine at one time is in the high hundreds. It's suspected that this is causing all ...
8
votes
1answer
1k views

Conceptually what does it mean when it is said that each thread gets its own stack?

I have been reading Java Concurrency in Practice by Brian Goetz and inside the section Stack Confinement it is mentioned that each thread gets its own stack and so local variables are intrinsically ...
1
vote
1answer
588 views

Multiple readers on FIFO

I've asked a question here before about multiple writers on a FIFO, and I know now that the write is thread safe as long as I write less than the PIPE_BIF, here is the link for that limit. What about ...
5
votes
3answers
661 views

Cloud computing platforms only have one CPU. Does this mean I shouldn't use Parallel Programming?

Almost every cloud instance I can find only offers one CPU. Why is this only one CPU now, and should I expect this to increase in the future? Does this design impact my code design so that I exclude ...
1
vote
3answers
691 views

Algorithm for appointment reminders

My program allows users to store appointments in a calendar. What has been requested of me is the ability for SMS reminders to be sent to people to remind them of their appointment. The SMS would ...
3
votes
1answer
184 views

How could one make a reasonably efficient, pointer-sized mutex?

I have my own ideas about how a pointer-sized mutex could be made: The integer is used as a set of flags, counter, index, and a spinlock that guards an entry in a table of pre-allocated kernel objects ...
5
votes
2answers
318 views

Good reasons for destroying mutexes with waiting threads

I'd like to see some valid examples of needing to let a thread enter a locked, non-re entrant mutex, then destroying the mutex (which supposedly terminates the thread). I can't think of any good ...
9
votes
3answers
987 views

Lock-free IPC in Linux for multi-core processors

I'm trying to find a way to write an application with lock-free IPC on Linux, in C, with multi-core processors. Let's assume I have process 1 and process 2 that write to a FIFO or shared memory. Then ...
1
vote
1answer
840 views

Clients with multiple proxy and multithreading callbacks

I created a sessionful web service using WCF, and in particular I used the NetTcpBinding binding. In addition to methods to initiate and terminate a session, other methods allow the client to send to ...
2
votes
2answers
394 views

Multi cores/CPUs with locks

I'm not sure how the locks will work with multi processors/cores, I'm going to use shared memory in my application or FIFO, what worries me is the locks, I have a server with 2-CPU, how the lock will ...