Same crash happened in CVI5.0 or CVI5.5 in Win98. Crash here means
the computer stops responding to any user input and I have to
press CTRL+ALT+DEL or restart PC.,
My program talks to a device through Parallel Port, so it's of no
big use sending the original code. I 'll try to describe the problem
as clear as I can.
I create a thread by CreateThread() and call a lot of function from
several DLLs in the thread. Normally the system resources is about
65% free. When the thread is started, free system resources reduced
dramatically to very low in less than half a minute until the whole
system stops responding.
The code is something like below:
* In CallFunc() I call functions from libraries and do a lot of
I/O.
// -------------------- Code Begin ---------------------------- //
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Thread_Loop,0,0,&ThreadID);
DWORD WINAPI Thread_Loop(LPVOID lpParam)
{
do{
// also tried CallFunc(1),CallFunc(2)...
CallFunc(7);
// add Delay here make things a little better, which means it
// can run for more times and then crash 🙂
Delay(0.5);
}while(!StopLoop);
}
// ---------------------- Code End ------------------------ //
When CallFunc() is called for about 11 times, it crashes.
And I tried other ways:
// -------------------- Code Begin ---------------------------- //
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Thread_Loop,0,0,&ThreadID);
DWORD WINAPI Thread_Loop(LPVOID lpParam)
{
CallFunc(1);
CallFunc(2);
CallFunc(3);
CallFunc(4);
CallFunc(5);
CallFunc(6);
CallFunc(7);
CallFunc(8);
CallFunc(9);
CallFunc(10);
CallFunc(11);
CallFunc(12);
}
// ---------------------- Code End ------------------------
//
When the thread comes to CallFunc(8) or so, it crashes.
The situation seems like resources such as memory not properly used
an released in the CallFunc(). But if I use CallFunc() directly,
not in thread, crash never happens.