02-16-2017 02:22 PM
Hi all !
I'm using the STM library (over TCP) to communicate between a client and a server (which are 2 cRIOs). 2 ports are opened (55000 and 56000) because I need to send 2 kind of messages.
On the first port small messages are sent often (82 bytes every 2ms). On the other port much larger data is sent but less often (160k bytes every 50ms).
The reader is reading each port in a separate loop. The timeout of the STM read is the only thing which rules the loop timing. So each loop should run as fast as they received the data (so approximately 500Hz for the first port, 20Hz for the second).
I noticed that every 50ms, the first loop takes almost 6 to 10ms instead of the usual 2ms. So it is quite clear that the second loop as an influence on the first one...
STM VIs are all reentrant... Is it the TCP/IP library which is no reentrant or the bottleneck is much deeper (in the TCP stack ?) ?
Is there any way that I can have my two loops running independently ?
02-16-2017 02:44 PM
I am fairly certain the the TCP/IP primitives are re-entrant; otherwise they would be a fairly useless language primitive. I suspect there is some other issue causing the blocking behaviour. Can you share the example that shows this?
02-16-2017 02:50 PM
The TCP/IP nodes are internally fully asynchronous except a few protected resource accesses around opening and closing of refnums. But they are typically very short and should not cause any noticable delay.
02-16-2017 02:54 PM - edited 02-16-2017 02:56 PM
The developpement is a VerisStand custom device, so it is hard to separate all things and post it here... I made some screen copies of my debug code...
Do not take care of comments written on the images, print screen have originally be made for another problem...
Can the processor work be suddenly high because of the 50ms amount of data arriving, and less priority is given to the 'fast loop' ?
02-16-2017 03:31 PM
Here is the screenshot showing what happens.
'fast loop' is in that case reading at 100HZ (10000us), and 'slow loop' is reading at 2Hz...
You can see from the print screen that every 2Hz (500ms), my fast loop rate goes from 10000us to 15000us....
02-16-2017 03:49 PM
@zyl7 wrote:
Here is the screenshot showing what happens.
'fast loop' is in that case reading at 100HZ (10000us), and 'slow loop' is reading at 2Hz...
You can see from the print screen that every 2Hz (500ms), my fast loop rate goes from 10000us to 15000us....
And then compensating right after with a loop that takes only 5000us. This looks to me more like a some contention you create yourself. Possible things could be some common subVI that you call in both loops that is not set to run reentrant, calling some other inherently non-reentrant functionality in both loops, or simply overloading your CPU in the case when it has to read those large messages and processing them in some way.
02-16-2017 04:04 PM
I checked reentrancy several times. I guess it is CPU, because if I reduce the amount of data to send or more often the drift is still there but less visible. The only common thing is the branch of an object...