multithreading

What's a good profiler for a CLI based multi-threaded PHP application?

I've written a batch processor that runs multiple threads (pcntl_fork) and I'm getting some weird results when child processes go defunct and don't seem to let go of their resources. Is there a good code profiler, trace utility I can use to 'watch' the parent process and children to see what is going on? ...

How long does a context switch take in Linux?

I'm curious how many cycles it takes to change contexts in Linux. I'm specifically using an E5405 Xeon (x64), but I'd love to see how it compares to other platforms as well. ...

Better multi-threaded debugging in the Delphi

Leading on from the answer to another question about bugs in the Delphi IDE, does anyone know if there is a way to improve the multi-threaded debugging functionality of the IDE, or if not, at least why it is so bad on occasion? When you have multiple threads within a program, stepping through the code with F7 or F8 can often lead to eit...

How do I create a thread that runs all the time in the background in a .net web site?

I intend to build a small web site that will poll a third party web service, say every 15 minutes, store the collected data in a db and display the results via web pages. I want the polling to run 24 hours a day with or without anyone visiting the web site. I know I could create a stand alone application that could run on the server ...

Do I need to lock STL list with mutex in push_back pop_front scenario?

I have a thread push-backing to STL list and another thread pop-fronting from the list. Do I need to lock the list with mutex in such case? ...

Does Interlocked provide visibility in all threads?

Suppose I have a variable "counter", and there are several threads accessing and setting the value of "counter" by using Interlocked, i.e.: int value = Interlocked.Increment(ref counter); and int value = Interlocked.Decrement(ref counter); Can I assume that, the change made by Interlocked will be visible in all threads? If not, w...

To Thread or not to Thread when starting an external application in C#

I'm creating a win service that monitors ftp logs, when a file has been uploaded I want to start an external application, like a powershell script, to do stuff with the file. my Question is do i want to spin this off into another thread when i do it or should I just wait until it finishes before moving on. This process is already goin...

Issues calling Dispatcher in WPF

I have some UI code that needs to be updated from my background presenter thread. So, I do the following: from my background thread, I set my property in the UI: _ui.ConnectionStatus = "A"; then, my set is as follows: public string ConnectionStatus { set{ if (Dispatcher.CheckAccess()) ConnectionStatusTxt.Content = value; else { ...

What thread does JavaScript code called from Flash execute on?

Hi, As far as I understand, all JavaScript code is event-driven and executes on a single browser thread. However, I have some JavaScript functions that are called from within a SWF object sitting on the same page. Is this code run in the same manner as regular JS code, or is it on some separate Flash thread? If it is on a separate thr...

Unexpected multithreaded result

I wrote a couple of Java classesSingleThreadedCompute and MultithreadedComputeto demonstrate the fact (or what I always thought was a fact!) that if you parallelize a compute-centric (no I/O) task on a single core machine, you don't get a speedup. Indeed my understanding is that parallelizing such tasks actually slows things down because...

Writing to a TextBox from another thread?

strong textI cannot figure out how to make a C# Windows Form application write to a textbox from a thread. For example in the Program.cs we have the standard main() that draws the form: static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); ...

Thread progress to GUI

I implemented threading in my application for scraping websites. After all the sites are scrapped I want to process them. form creates queueworker(which creates 2 workers and processes tasks). After all the tasks are done I want to process them baack in the formthread. At this point I accieved this with public void WaitForCompletion() ...

What are common concurrency pitfalls?

I'm looking into educating our team on concurrency. What are the most common pitfalls developers fall into surrounding concurrency. For instance, in .Net the keyword static opens the door to a lot of concurrency issues. Are there other design patterns that are not thread safe? Update There are so many great answers here it is difficul...

Passing a work item between threads (Java)

I have two threads. The producer is producing pieces of data (String objects), where the consumer processes these strings. The catch is that my application only needs the most recent data object to be processed. In other words, if the producer managed to produce two strings "s1" and then "s2" then I want the consumer to process only "s2"...

Learning C properly: yes or no?

My primary language is PHP, but I have done some (not very much) programming in other languages. I've written 2 modules for Apache in C. I wrote them in C because this was one of the things where performance did matter. (generating projected maps of the world on the fly and output to .png). These modules work, and that's as far as I ca...

Display loading message while Exporting a results set to Excel

Hi Everyone, I'm using ASP.NET and C# and am exporting a very large results set to Excel. While my export code is running I would like to show a "loading" animated gif so the users will know their request is processing. I've been trying to do this with multithreading, but I am not very familiar with it. Can anyone guide me in the rig...

C# 1.1: Monitoring worker threads

Using the .Net Framework 1.1, what options are available for monitoring threads from other threads? I am attempting to deal with a shortcoming of the threading implementation in 1.1 wherein unhandled exceptions will cause threads to die silently. In 2.0 and later this had been corrected so that any unhandled exception on any thread wil...

.NET - Find external applications main thread ID.

I'm trying to find the handle of the main thread of an external application. The program I am trying to find the main thread of is multithreaded and it is important I always find the main thread. I know that at most there will be one copy of this program running. This is how I am doing it at the moment: Process[] someProcesses = Process...

How do I limit an external DLL to one CPU?

I have a program that I would like to run on just one CPU so it doesn't take up too much system resources. The problem is, it makes a call into an external DLL that automatically uses all available CPU cores. I do not have the source code to the external DLL. How can I limit the DLL to only using one CPU? EDIT: Thanks for the help, here...

How to get error messages from ruby threads

I'm having a problem right now where I can't see where my child threads are spitting out error messages which is making it difficult to debug. eg: Thread.new{ a = 1/0 } Is there any way to have all thread errors print out at stderr? ...