multithreading

Doesn't the fact that Go and Java use User space thread mean that you can't really take advantage of multiple core?

We've been talking about threads in my operating system class a lot lately and one question has come to my mind. Since Go, (and Java) uses User-space thread instead of kernel threads, doesn't that mean that you can't effectively take advantages of multiple cores since the OS only allocates CPU time to the process and not the threads th...

Difference between multithreaded and parallel programming

Is there a difference between multithreaded and parallel programming? If related (which I guess they are) is parallel programming the successor of multithreaded programming in terms of terminology? The reason I am asking is because I want to buy a book on one (maybe both) of the above. ...

Python threading strange behaviour.

from threading import * from time import * class MyThread(Thread): def __init__(self,x): self.x = x Thread.__init__(self) def run(self): sleep(2) print(self.x) if __name__=='__main__': threads = [] for i in range(5): threads.append(MyThread('Hello')) for i in range(5): threads[i].s...

How can I check if a function is being called on a particular Thread?

If I have Thread A which is the main Application Thread and a secondary Thread. How can I check if a function is being called within Thread B? Basically I am trying to implement the following code snippit: public void ensureRunningOnCorrectThread() { if( function is being called within ThreadB ) { performIO() } ...

How to synchronize Swing model with a rapidly changing "real" model?

As is widely known, anything related to Swing components must be done on the event dispatch thread. This also applies to the models behind the components, such as TableModel. Easy enough in elementary cases, but things become pretty complicated if the model is a "live view" of something that must run on a separate thread because it's cha...

Delphi MREW implementation that favors readers?

Is there a Delphi implementation of an MREW (multiple read, exclusive write) lock, that favors reading over writing? ...

How to programmatically tell if two variables are on the same stack? (in Windows)

I'm in a thread. I have an address. Is that address from a variable on the same stack that I'm using? static int *address; void A() { int x; atomic::CAS(address, 0, &x); // ie address = &x // ... } void B() { int y; int * addr = atomic::read(address); // ie addr = address if (addr && on_same_stack(&y, addr)) ...

Displaying a "Please Wait" Dialog for a Non-Thread Safe task.

I am using 3rd party library and some of the functions of the library take a long time to execute so I want to display a "Please Wait" dialog while the functions are busy. Normally I would do something like this: Thread longTask = new Thread (new ThreadStart(LongTask)); longTask.IsBackgroud = true; longTask.Start(); pleaseWaitForm = n...

Cache Line Alignment (Need clarification on article)

I've recently encountered what I think is a false-sharing problem in my application, and I've looked up Sutter's article on how to align my data to cache lines. He suggests the following C++ code: // C++ (using C++0x alignment syntax) template<typename T> struct cache_line_storage { [[ align(CACHE_LINE_SIZE) ]] T data; char pad[ C...

Debug recursive thread call in C

I have been trying to debug my code whenever I had free-time for the past day and a half and I don't know what is wrong with my code. When I add the close() function to a recursive call, the program gives me an invalid pointer. But when I remove the close() function call the program runs fine, except it does not do what it is supposed to...

MFC multithreading problem with delete[] , dbgheap.c

Hi! I've got a strange problem and really don't understand what's going on. I made my application multithreaded using the MFC multithreadclasses. Everything works well so far, but now: somewhere in the beginning of the code i create the threads: m_bucketCreator = new BucketCreator(128,128,32); CEvent* updateEvent = new ...

Semaphores in .NET compact framework

Unfortunately, there is no Semaphore in System.Threading when using the .NET Compact Framework. I'm not sure why that is, does anyone have an idea? After googling I've found a bunch of people giving their own implementations, but none of them really worked great... or at all! So I've come to ask the experts... Does anyone have a good...

Segmentation fault only when running on multi-core

I am using a c++ library that is meant to be multi-threaded and the number of working threads can be set using a variable. The library uses pthreads. The problem appears when I run the application ,that is provided as a test of library, on a quad-core machine using 3 threads or more. The application exits with a segmentation fault runtim...

Checking for open port on multiple machines.

Hi everyone, I have a program which pulls a list of ip addresses from a database, around 3000 in total. Each address relates to a remote machine which should be running a .NET Remoting server to which my application is the client. I need to connect to each to pull back some data via .Net Remoting. However if there is some sort of proble...

Separate threads for socket input and output

I got assigned to work on some performance and random crashing issues of a multi-threaded java server. Even though threads and thread-safety are not really new topics for me, I found out designing a new multi-threaded application is probably half as difficult as trying to tweak some legacy code. I skimmed through some well known books in...

Non-blocking I/O versus using threads (How bad is context switching?)

We use sockets a lot in a program that I work on and we handle connections from up to about 100 machines simultaneously at times. We have a combination of non-blocking I/O in use with a state table to manage it and traditional Java sockets which use threads. We have quite a few problems with non-blocking sockets and I personally like...

Why does my WCF service method only work once I've called MessageBox.Show()?

I have a WCF service which provides a method that creates a file. Sometimes it takes a little while for this file to appear, and other methods which are relying on that file's existence fail if they are called immediately afterward. As a result, I want to check that the file has appeared before proceeding. In my client class, I can call...

Getting from ProcessThread to a managed thread

Periodically we get a hang on shut down of a Windows service in a production environment that we just cannot reproduce. It can be months before it happens again. I'm putting in some diagnostics to try and help with the issue, one thing I'm looking at is adding an event to the system thread pool for 60 seconds after we initiate shut down...

Are thread and process ids unique?

I am using a static library; it has a function which uses the current time and creates a unique id, which is then inserted into my database. This number should be unique in my database table. There are two processes running in parallel. Sometimes they simultaneously call this function, and the same number is generated. I get an integr...

C# server - is this good way for timeouting and disconnecting?

Hi, On my multithreaded server I am experiencincg troubles with connections that are not coming from the proper Client and so hang unathorized. I did not want to create new thread only for checking if clients are connected for some time without authorization. Instead of this, I have add this checking to RecieveData thread, shown on the c...