PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

thread monitor on realtime system

Solved!
Go to solution

I have a PXIe-8101 controller in my PXI system. I have it running with a realtime operating system. I inherited some CAN software that was used on a LabWindows program used on a PC with a Windows 7 operating system. The CAN software seems to run OK. My problem is when I exit the program I get a NON-FATAL RUN-TIME ERROR

 

"

Unknown source position thread id 0x000000EC

Your CVI program has exited on the real-time target. However, there are still threads on the real-time target that are running or have previously run CVI code.

Please verify that your application cleans up all of its threads. Threads left running after your application exits can crash the real-time target when your application is unloaded.

"

 

As  I said I inherited the code and there is a lot of it. I am looking for a clever way to hunt down these threads. I was wondering if there are any tools available that could help with this? Or any other suggestions on how to run these down?

 

 

 

 

0 Kudos
Message 1 of 3
(4,220 Views)

I've narrowed down my problem a bit so wanted to add this information. I think I found the phantom thread.

I created it with this function call.

 

    cmtStatus = CmtNewThreadPool(2, &cop_thread_pool);

 

So I thin this is great; all I need to do is call: CmtDiscardThreadPool() and the thread will be stopped. So I call it:

 

   CmtDiscardThreadPool (cop_thread_pool);

 

But this causes my program to hang. I look at the help on CmtDiscardThreadPool() and it says:

"

Do not call this function while you are inside a DLL DllMain function. If you call CmtDiscardThreadPool from DLLMain, your program will hang.

"

Since my program is a realtime application and is a DLL ( my main is void CVIFUNC_C RTmain (void)) I figure this must apply to my program too.

 

My questions:

Is my understanding of this correct?

What would be a good way to fix this problem?

Should I start the thread in another way for this DLL?

 

 

0 Kudos
Message 2 of 3
(4,213 Views)
Solution
Accepted by topic author DPearce

Hi DPearce,

 

This KnowledgeBase article has some information about why CmtDiscardThreadPool causes your program to hang and gives some recommendations for fixing it.

Jayme W.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 3
(4,204 Views)