1
Vote

Threads dont start on Server 2003 4CPU machine

description

I have created a very simple application which does the following:
  1. Create a SmartThreadPool
  2. Queue 5 work items
  3. Pause 10 seconds
  4. Go to 2
The work items sleep for 1 second then return.

So we should get:
5 work items created,
5 work items started,
5 work items finished.
(pause)
5 work items created,
5 work items started,
5 work items finished.
(pause)
5 work items created,
5 work items started,
5 work items finished.
(pause)

This fails on a Windows Server 2003 SP2 4-cpu machine.

Instead, we get:

5 work items created,
5 work items started,
5 work items finished.
(pause)
5 work items created,
(pause)
5 work items created,
5 work items started,
5 work items finished.
(pause)
5 work items created,
(pause)
5 work items created,
5 work items started,
5 work items finished.
(pause)
5 work items created,
(pause)

On every second iteration, none of the work items start.


It worked on the following:
Windows Server 2003 SP2 2-cpu
Windows 7

The software is attached.

I tried setting the processor affinity to limit the software to 1 CPU but this made no difference.

Please can you help!

file attachments

comments

alansingfield wrote Mar 24, 2010 at 11:33 AM

OK - found the problem.

The broken server had .NET Framework 3.5 rather than .NET Framework 3.5 SP1 on it.

I changed my demo code to use the SmartThreadPool.WaitForIdle(10000) rather than Sleep(10000) to see if this would make a difference, and surprisingly, this gave me a MissingMethodException (only on the broken server).

There is a new overload "bool WaitHandle.WaitOne(int32)" introduced in SP1 which throws this MissingMethodException when called on non-SP1 machines.

http://blog.darrenstokes.com/2009/03/30/watch-out-for-those-waitone-overloads-when-you-need-backwards-compatibility/

Can I suggest that you change the WaitOne(int32) calls to WaitOne(int32, false) so SP1 is not a prerequisite?

Alternatively, put a version check into the library to warn of this problem.

HakanL wrote Jun 15, 2013 at 2:55 AM

I had the exact same problem on a machine that only has .NET 2.0 sp0. I've made a change to STP to not use the .NET 2.0 sp2 WaitOne/WaitAll/WaitAny methods. I'll see how I can submit a patch here.