multithreading

Critical sections with multicore processors

With a single-core processor, where all your threads are run from the one single CPU, the idea of implementing a critical section using an atomic test-and-set operation on some mutex (or semaphore or etc) in memory seems straightforward enough; because your processor is executing a test-and-set from one spot in your program, it necessari...

Custom multithreading loop

Hi, I am looking into using a producer\consumer threading pattern to run through a list of strings that i retrieve from a database and then am going to run powershell commands against. As the powershell commands can be quite intensive i only want to spawn 3 threads at a time and then wait for one thread to finish before doing anymore. I...

C Programming: Debugging with pthreads

One of the hardest things for me to initially adjust to was my first intense experience programming with pthreads in C. I was used to knowing exactly what the next line of code to be run would be and most of my debugging techniques centered around that expectation. What are some good techniques to debugging with pthreads in C? You can s...

Is there an API to set a NTFS ACL only on a particular folder without flowing permissions down?

In my environment, I have several projects that involve running NTFS ACL audit reports and various ACL cleanup activities on a number of file servers. There are two main reasons why I cannot perform these activities locally on the servers: 1) I do not have local access to the servers as they are actually owned and administered by anothe...

Lock free hash table for c#

Does anyone know of an implementation of a lock free hash table in C#? Or can anyone confirm for a fact that at least reads on a HashTable are thread-safe? Edit: I can read the documentation, but it's unclear. "It is thread safe for multi-thread use when only one of the threads perform write (update) operations." So, the question is...

Multithreaded file access

I am writing a hex editor program and I was thinking about when a user tries to open a very large file (3GB+). I wouldn't want the user to sit around all day for the whole file to load when it already has some data loaded. So here is my question, would it be possible to have multiple threads read the file (not write) simultaneously, at ...

How to do a non-blocking URL fetch in Python

I am writing a GUI app in Pyglet that has to display tens to hundreds of thumbnails from the Internet. Right now, I am using urllib.urlretrieve to grab them, but this blocks each time until they are finished, and only grabs one at a time. I would prefer to download them in parallel and have each one display as soon as it's finished, wit...

Update Winforms UI from background thread result

This is probably a silly question, but I could not find an answer on stackoverflow. I have a button click event in a Winform app that runs a thread to caclulate a result to display in a form. How do I update the Forms UI when the thread has calculated the result? private void btnRequestR2Approval_Click(object sender, EventArgs e...

Is Interlocked enough for this situation ?

I have a multithreaded application (C++) where I need to increment/change a series of values. If I use a series of Interlocked operations, are they considered to be a single atomic operation ? Like in this example: InterlockedIncrement(&value1); InterlockedIncrement(&value2); InterlockedExchange(&oldValue, newValue); Or it would be be...

Python Subprocess.Popen from a thread

I'm trying to launch an 'rsync' using subprocess module and Popen inside of a thread. After I call the rsync I need to read the output as well. I'm using the communicate method to read the output. The code runs fine when I do not use a thread. It appears that when I use a thread it hangs on the communicate call. Another thing I've notice...

How to update a MATLAB GUI in the background?

I have a MATLAB GUI and a separate application that writes data to a file. I'd like my MATLAB GUI to check the file periodically, and update the GUI when it changes. In Java, I'd use a SwingUtils.Timer(sp?) object to do something like this. Does MATLAB have timer functionality? I could write a java class and do it I suppose, but want ...

Call cancel on thread when pressing ctrl+c

I've written a console application that basically fires one BackgroundWorker that supports ReportProgress and Cancel. How can I make sure that before a window is closed (by pressing the close button or pressing ctrl+c) the cancel operation is triggered on my thread and the window only closes after the cancel is completed? ...

Why does line 58(notifyAll();) in the following code throw an IllegalMonitorStateException and still produce the correct output?

public class Reader extends Thread{ Calculator c; public Reader(Calculator cal) { c=cal; } public void run() { synchronized(c) { try { System.out.println(""+Thread.currentThread().getName()+" waiting for calculation"); c.wait(); } catch(InterruptedException e) ...

C# threading and Windows Forms

Is my approach to a responsive GUI with a background process correct? If not, please please critique and offer improvements. In particular, indicate what code could potentially suffer from a deadlock or race condition. The worker thread needs to be able to be cancelled and report it's progress. I didn't use a BackgroundWorker because...

Python thread exit code

Is there a way to tell if a thread has exited normally or because of an exception? ...

How can I get cross-thread communication in a Perl GTK program?

I have a Perl program that has a GTK2 GUI (via the Gtk2 package). This program also opens a network socket (actually via LWP) in another thread, and continuously makes a request for a certain URL, waiting for an event to happen. If an event occurs, then its data must be processed and interpreted, and an appropriate callback function use...

asp.net :does dot net platform 3.5 impose any limit on number of thread of threads to be run at a time if it does what is limit ?

hey i am using threads on my own not using thread pool.each thread is making web request .so is there any restriction from platform side fr number of threads to be used .or it will just degrade performance ? ...

VS 7.1 Release compile and multiple threads

VS 7.1 release mode does not seem to be properly parallelizing threads while debug mode does. Here is a summary of what is happening. First, for what it's worth, here is the main piece of code that parallelizes, but I don't think it's an issue: // parallelize the search CWinThread* thread[THREADS]; for ( i = 0; i ...

About thread safety in malloc and free

Possible Duplicate: Malloc thread-safe? I heard that glibc malloc() was not thread safe, since several threads of a process calling malloc() simultaneously will lead to undefined behaviour. And my question is if a thread calls free() will another thread is calling malloc(), will this lead to undefined behaviour as well? ...

Using BackgroundWorker to update the UI without freezes...?

I have the following code for population a ListView from a background thread (DoWork calls the PopulateThread method): delegate void PopulateThreadCallBack(DoWorkEventArgs e); private void PopulateThread(DoWorkEventArgs e) { if (this.InvokeRequired) { PopulateThreadCallBack d = new PopulateThreadCallBack(this.PopulateTh...