10-31-2011 02:44 PM
I'm having an issue with making function calls from multiple threads. There are two threads that each call a function called save_program, to which a DDCChannelHandleGroup and and a certain "pulse program" structure are passed. The problem I'm having is that after I've called save_program from one of the threads, it locks up when I try to call it from the other thread. There are three contexts for this - two in the main thread and one in the data acquisition thread.
If I call save_program from either of the contexts in the main thread, the program locks up when I try to call it in the data acquisition thread, and vice versa. Calling from the two contexts within the same thread doesn't cause any issue. I've set a breakpoint at the function call and at the first piece of executable code in save_program (variable declaration initialized to NULL), and the program freezes between those two breakpoints. I've checked and execution always does fully complete in each of the threads AND the CmtExitThreadPoolThread() call also executes just fine. I've also encased all instances of save_program in CmtGetLock/CmtReleaseLock calls to no avail. Bizarrely, these calls used to cause no problems with the exact same multithreading setup. I'm not sure what has changed.
Solved! Go to Solution.
11-01-2011 01:49 PM
It is very possible you have come across a known issue within LabWindows/CVI where all operations must be completed before calling SaveFile. I have included a link below that talks a little bit more about this issue.
This is an issue that has been reported and is being handled by R&D. As of now, there is not a bug fix available however hopefully we can find a work around that will work for your application.
Please let me know if you have any further questions.
11-01-2011 03:03 PM
Thanks so much, this is definitely what the issue was. I had been just keeping the "current file" open and writing to it and saving the data intermittently. Opening the file and closing it immediately after I write the data fixes this issue.
11-02-2011 09:10 AM
Excellent, glad to hear you got it figured out!