09-24-2008 11:35 AM
I have a RT high priority 1 kHz timed event loop that occasionally needs to send something to a shared variable via a data socket write. I'm using a timeout of 0 for the DS write which should be fire-and-forget. But what I'm seeing is that this allows a lower-priority thread to preempt the high priority thread for over 15 ms. Classic priority inversion. If I disable the DS write, things run smoothly. I would have expected that the DS write was safe to call from a high-priority thread. Is it taking a system-wide mutex to talk on the socket? The DS it's writing to is not used in any other threads on the target, so I'm perplexed by this. Should I not be using DS from a high-priority high-frequency thread? Should I instead use a RT FIFO to talk to a DS?
Thanks,
Keith.
09-24-2008 05:32 PM
I'm not even sure how I'd use an RT FIFO. I have a DS reference and the value (boolean or timestamp). The FIFO only stores arrays of simple types. Any ideas? Do I create a cluster, flatten it to a string, then convert the string to a byte array? That seems pretty round-about ...
Keith.
09-25-2008 12:40 PM
Hello Keith,
> Should I not be using DS from a high-priority high-frequency thread?
Network communication should not be done from the time-critical or highest priority threads.
Could you post the portion of the code that you are speaking of, so that we can better visualize what you are describing?
Here is a comparison of some of the different communication methods. Since you are speaking of priorities, are you using Real-Time?
Real-Time VI to Host VI Communication Methods
http://digital.ni.com/public.nsf/allkb/48D244EC86971D3986256BD4005CCC28?OpenDocument