Subj : Re: Hyper Threading / Multi-Threaded Queue / Application Freezes To : comp.programming.threads From : junker98 Date : Wed Apr 20 2005 06:37 am "Shaw" wrote in message news:<1113316445.845312.71210@z14g2000cwz.googlegroups.com>... > have an MFC application which contains a queue which is accessed by > multiple threads. The main application thread is used to add items to > the queue, while I have a worker thread which is used for taking items > from the queue and passing them to another application. > > The queue is implemented using the MFC CList class, and add/remove > operations are guarded by a critical section, therefore access to the > queue is synchronized ( I hope ). > > My problem is this program has run great on 100's of machines for well > over 12months, however recently has been tested on a Hyper-Threaded XP > SP2 machine - and for some reasons the application locks up > periodically. By "locks up", I mean the application frame freezes (not > responding) for up to 10-20secs at a time and then returns to normal > again. Seems there is some sort of livelock/deadlocal between the > add/remove operations - however I can't work it out. > > Is there a problem with critical sections and multi threads on HT > machines? Anyone had similar problems to this before? > > I can post code snippets if needs be... > > Help (pls) > > Wal Have you tried running your application on a true multiprocessor box? Running threaded code on a Hyperthreaded or Multiprocessor machine will often expose threading bugs that go undetected on Uniprocessor machines. I've had numerous experiences with multithreaded code developed on a single processor machine crashing or hanging when run on multiprocessor machines due to the increased concurrency of these systems. If it runs fine on a multiprocessor box I'd suspect a problem with Hyperthreading, but if this is not possible to test, I'd spend a bit of time with the debugger trying to figure out what is going wrong. Does you code do anything else aside from the add/remove operations while holding the critical section? Is it definitely the synchronisation of this queue that is causing the hang? .