LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

My CVI 6.0 program has four TCP/IP client callback and RunUserInterface, whithout any multithreading. Do I create separate threads to have improved performance?

My program developed in LabWindows/CVI. I have four (4) different callback function from Ethernet as Client.
There are in each a
switch (xType) {
case TCP_DISCONNECT:
....
case TCP_DATAREADY:
....
Some times the program is block on an old PC
having 100 MHz and 64 Mbyte.
I suppose there is some performance problem, because
the four TCP channels have 1 kHz sampling rate.
Would be help to implement multithreading?
0 Kudos
Message 1 of 6
(3,752 Views)
Hi Sanyi1939,

I found a couple of tutorials on multithreaded programming in CVI that may be useful.

Easy Multithreading programming in CVI

Building multithreaded applications in CVI

If you are using 4 TCP channels to transfer data between machines, a multithreaded application might help improve your performance. You would want to then design your application to have a thread for each TCP channel. One weakness to this however, is if you decide to combine the data into a single object, then you must worry about
race conditions and mutual exclusion. Hope this helps!

Jeremy L.
National Instruments
Jeremy L.
National Instruments
0 Kudos
Message 2 of 6
(3,752 Views)
In the "Applications Note 194" there are a few sentenses (page 16):
""""""""""""""""""""
With some of the LabWindows/CVI libraries, you can receive callbacks in a system-created thread. Because these libraries automatically create threads that execute your callbacks, you do not have to create threads or schedule a function to run in a separate thread. You still have to protect data that is shared between these threads and other threads in your program. Invocations of these callbacks are typically referred to as asynchronous events.
""""""""""""""""""""
which are confused me. In my user interface I handle
separetly the data from different TCP/IP sources, but
I have to store data into a common file.
0 Kudos
Message 3 of 6
(3,752 Views)
In the "Applications Note 194" there are a few sentenses (page 16):
""""""""""""""""""""
With some of the LabWindows/CVI libraries, you can receive callbacks in a system-created thread. Because these libraries automatically create threads that execute your callbacks, you do not have to create threads or schedule a function to run in a separate thread. You still have to protect data that is shared between these threads and other threads in your program. Invocations of these callbacks are typically referred to as asynchronous events.
""""""""""""""""""""
which are confused me. In my user interface I handle
separetly the data from different TCP/IP sources, but
I have to store data into a common file.
0 Kudos
Message 4 of 6
(3,752 Views)
Hi Sanyi1939,

Actually, the libraries that automatically create threads are the ones listed in the following three paragraphs. IF you are not using any of these libraries, then you would have to create and schedule the threads manually.

Since you plan on storing all of your data into a common file, you will have to utilize thread locks. In the applications note, there is a section that gives a good overview and brief tutorial about protecting data.

Jeremy L.
National Instruments
Jeremy L.
National Instruments
0 Kudos
Message 5 of 6
(3,752 Views)
So, I have to create and schedule the threads manually for each TCP/IP callback fuctions and I have to organize
in the same threads their visualisation. The storage in a common data file is other problem, I have to utilize thread locks.
0 Kudos
Message 6 of 6
(3,752 Views)