05-01-2006 01:39 PM
What can cause the scheduler to reschedule the same thread while the first execution of the thread hasn’t completed? Along the same lines, what can make a Callback be required to be reentered? Are there any library calls that it would call?
I have a multi-threaded application where I am using Threads created using LabWindows functions. The three cases that I am wondering about especially in relation to any use of “static variables” are as follows:
Are callbacks handled differently from thread executions? I used LabWindows to build the .uir files but I am compiling using Visual Studio because Visual Studio can handle C++ and LabWindows/CVI cannot. Does this fact come into play regarding the answering of my questions?
05-01-2006 05:53 PM
05-02-2006 09:58 AM
05-02-2006 11:48 AM
Hi Luis,
There are two events that we are concerned about. One is a reader callback from a thread safe queue. The other is a UI callback. We are concerned about have to make sure our code is re-entrant. We know that if there is a MessagePopup call that the callback can be called again while waiting for the popup to be acknowledged (so this code needs to be re-entrant). What other cases/calls could cause a callback to be called re-entrantly?
Also, we use function CmtScheduleThreadPoolFunctionAdv to create our threads. We compile under Visual C++ 6.0. In another post we were told that this could be a problem in this environment. Are you aware of any issues and if so what are they?
Thanks,
Donna
05-03-2006 12:39 PM
05-03-2006 01:18 PM
Thank you Luis for your response. We have to do study some things and we may have more questions regarding your answer. I do have an additional area that may or may not be related.
When we execute a CmtWriteTSQData call, sometimes we receive error # -14912 which according to LabWindows online help means "This thread or another thread is currently writing to the thread safe queue." We stopped in the degger right after the check for the return value of CmtWriteTSQData and when we did a next in the debugger, we received an AcessViolation C00000005. I have a few questions about this.
1. Why is this not handled by Lab/Windows and why is this flagged as an error?
2. How can I code to prevent this from happening? I have multi threads running in my application and I don't know how to prevent this condition from happening.
3. If I have to put in some special code to avoid this type of error from occurring, are there any other error conditions that I would need to put protection code in for?
Thanks,
Donna
05-04-2006 10:53 AM
05-04-2006 11:01 AM
Luis,
Thanks for your response. Would you expect to see an Acess Violation if we did have concurrent access to the same queue?
Donna
05-04-2006 11:27 AM
05-04-2006 11:28 AM