LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

multithreading

Hello
 
I have programmed a thread safe queue to acquire and display data on a strip chart in real time. I have now to do a PID loop to correct my system amd I do have some problem with multithreading :
 
I have actually created two threadpool : one for data acquisition and the second one for the PID loop
I have thread threads : the main one for data acquisition, the second one for ploting data and the last one for the PID.
 
And I observe :
Before launching the data acquisition, the PID work
When I have launched, data acquisition, it does not react anymore....as they could not work all together.
 
If somebody knew how to fix this, I would be glad...
 
Thanks in advance
 
Estelle
 
0 Kudos
Message 1 of 7
(3,824 Views)
Could it be that you have configure different priorities for your threads? If you set the priority of your "data acquisition" thread to a very high priority, it can starve the other threads. Best would be to set all threads to the same priority first, and then adjust priorities step by step, until all run smoothly.

Another thing you have to take care of are locks. If you use thread locks to synchronize your threads you have to check these. Maybe you have a deadlock there.

Hope this helps! Maybe you could post your code, so that we can have a look at it.
0 Kudos
Message 2 of 7
(3,787 Views)
Hi,
 
I hace attached my code : I have no priority set on ....maybe I should synchonize something, I have really a new user of Labwindows ...
 
 
0 Kudos
Message 3 of 7
(3,776 Views)

Hello,

I think the issue is located in the call at "CmtReadTSQData" (inside the Notify function).

In your call, you pass 0 to the last argument.

If you pass 0, the data you read is discarded from the TSQ.

You must pass OPT_TSQ_READ_PEEK to leave the data in the TSQ, so the same data can be read more than once (tipically by other threads).

Hope this help

0 Kudos
Message 4 of 7
(3,773 Views)

Hi

In fact, the queue is working well, I can read the dat as I want but when I am acquiring data, the pid loop in not acting.

Thanks for your help , I think also that I had a mistake in that point

Estelle

0 Kudos
Message 5 of 7
(3,762 Views)
You can have a look at the attached example. There are two threads writing in one queue, andf one thread reading from it.
I had a look at your sorcecode, and saw, that you are stating threads in a callback, and waiting fro its completion afterwards. This does not make so much sense from my point opf view, because your main-thread will hang until your started thread finishes, and so you could implment the functionallity of your new thread directly in the callback, without any different behaviour. Maybe if you check out the example you can improve the thread scheduling in your application.

Hope this helps!

Message Edited by Andre_Saller on 07-17-2006 10:03 AM

0 Kudos
Message 6 of 7
(3,760 Views)

thanks for your help, actually I had also a problem on my Pid loop...

 

estelle

0 Kudos
Message 7 of 7
(3,748 Views)