Community
cancel
Showing results for 
Search instead for 
Did you mean: 
yashnxt
Beginner
77 Views

Multithreaded COM EXE Misbehaves under Intel XEON Hyper Threading

Hi Everybody,
I have an ATL COM Exe which internally spawns threads for doing the task rapidly, at the same time it takes the information from the Global Data & from certain events, The global data & Events are properly guarded with Syncronization, so that only one thread can read or write data into the global variable, the other threads are expected to wait until the previous thread finishes its job of modifying the global data. The Product has been tested on Intel Pentium III & IV, and has passed through the QA department. But at the client side, where the client has an Intel XEON Processor with HT, the EXEs started misbehaving.

Regards,
YASH
0 Kudos
5 Replies
Intel_C_Intel
Employee
77 Views

Hi Yash,
Could you be a little bit more specific as to what kind of the misbehaviour it is? Is it a race condition or a deadlock? or something totally different?
Other questions I would like to ask are:
Did you link with the thread-safe version of the runtime library? Did the code work in multiprocessing environment without HT/Xeon such as 2-processor Pentium III?

Regards,

Shuo
yashnxt
Beginner
77 Views

First of all sorry for my late reply.

I have four ATL COM EXEs, when i want to start those exes a Control or Admin EXE is started which internally starts the four main exes. The exes are tested on multiprocessor environment and they work properly. But at the client side when the Admin Exe starts, the Admin Exe also successfully initlize the COM Exe but only two or some times all four exes were started & in sometimes all the exes are started but then after some time any two exes are automatically terminated, there is no exception no log information is found. Then our support team stopped the Hyper Threading on the client side & everything started working properly. There is no dead lock or any other problem, because all the global resourcses are properly guarded with syncronization objects.

You had told about thread-safe run time library, can you please tell me more about thread-safe, iam also trying to figure out the problem & about thread-safe issue.

Thanks for your reply.

Thanks & Regards,
YASH


Intel_C_Intel
Employee
77 Views

> First of all sorry for my late reply.
>
> I have four ATL COM EXEs, when i want to start those
> exes a Control or Admin EXE is started which
> internally starts the four main exes. The exes are
> tested on multiprocessor environment and they work
> properly. But at the client side when the Admin Exe
> starts, the Admin Exe also successfully initlize the
> COM Exe but only two or some times all four exes were
> started & in sometimes all the exes are started but
> then after some time any two exes are automatically
> terminated, there is no exception no log information
> is found. Then our support team stopped the Hyper
> Threading on the client side & everything started
> working properly. There is no dead lock or any other
> problem, because all the global resourcses are
> properly guarded with syncronization objects.
>
Hi YASH,
I am not sure if this reply is late or not. If your program work on multiprocessor systems and indeed is indeed making use of more than just one CPU, your program should be MT correct.
My only suggestion is that make sure you are using the latest firmware on your HT enables system. If it's possible try it on other HT enbaled system, Xeon DP or 3.06GHz Desktop system.

> You had told about thread-safe run time library, can
> you please tell me more about thread-safe, iam also
> trying to figure out the problem & about thread-safe
> issue.
>
Here I am talking about C library in multithreaded environment. Depending on how recent your code is, on Visual C++ IDE, you may want to the following things:
1, Link with LIBCMT.LIB and override the default library.
2, Include #define _MT in all source files that use C library
3, Include for the _beginthreadex and _endthreadex definitions
4, Create threads with _beginthreadex.
5, Terminate threads with _endthreadex.

One of the early thread reference book is Win32 System Programming by John M. Hart. It's also the place where my suggestions were stolen from.

Good Luck on your thread debugging

Shuo
> Thanks for your reply.
>
> Thanks & Regards,
> YASH
>
>

ClayB
Black Belt
77 Views

YASH -

> There is no dead lock or any other
> problem, because all the global resourcses are
> properly guarded with syncronization objects.

This is quite a bold statement. It is easy to miss some critical shared resource that may not cause problems until you run in a different environment (like a system with Hyper-Threading turned on). The differences alter the timing and interactions between threads so that problems that didn't show up on development systems, now plague execution. Have you considered trying the Intel Thread Checker to double check that thread access to global resources are properly synchronized?

> You had told about thread-safe run time library, can
> you please tell me more about thread-safe, iam also
> trying to figure out the problem & about thread-safe
> issue.

A library function is thread safe if two or more threads can be executing the function without harmful side effects. Access to any static data used must be protected. Not just threads calling the same function must be considered, but the interactions of threads calling any two functions that use the same static data must be able to execute concurrently for the library to be considered thread safe.

The Microsoft C run-time libraries have a thread safe version. There is the additional overhead for using these because of the extra synchronization that is required. Library documentation should note if any functions are not thread safe or if thread safe alternatives are available.

-- clay
yashnxt
Beginner
77 Views

Thanks for the reply, the issue has been resolved, the problem was in a latest third party component, which use to misbehave in multiprocessor environment.

Thanks & Regards,
YASH.
Reply