I almost completed skeleton code for C# implementation and it was time to test. I did several round of testing with various configurations on different machines. I found a strange defect in code which took me almost 5 hours to resolve. Below is a screenshot where the application hangs as main thread waits for all child thread to complete. You can see the application stopped after 47 iterations.
The error was with following code.
Interlocked.Decrement(ref threadStartedCounter);
This is supposed to "Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation." but i figured out it was not on Windows XP when I had 16 threads on 2 core processor. I modified the code not to use Interlocked class and it was working fine.
If you are testing on XP (chances are high as when Vista was developed it was not Microsoft's finest hour) , you might have to apply patch below so that optimum use of cores takes place.
http://support.microsoft.com/kb/896256
Now I have to take readings which will be published in next post.
Interlocked.Decrement(ref threadStartedCounter);
This is supposed to "Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation." but i figured out it was not on Windows XP when I had 16 threads on 2 core processor. I modified the code not to use Interlocked class and it was working fine.
If you are testing on XP (chances are high as when Vista was developed it was not Microsoft's finest hour) , you might have to apply patch below so that optimum use of cores takes place.
http://support.microsoft.com/kb/896256
Now I have to take readings which will be published in next post.
No comments:
Post a Comment