09-12-2006 12:26 PM
09-12-2006 02:59 PM
Sounds like a dangerous (dead-lock prone) way to go about things. I don't have the RT package, but the theory should be similar to the regular Wait Until Next function. Take a peek at this tutorial: http://zone.ni.com/devzone/conceptd.nsf/webmain/E83351E12CD2D50886256B66006E4D15#2
09-12-2006 03:00 PM
If your normal-priority fast loop "stops executing", then it's either starved for CPU or your termination condition is being met, right? From your description, it shouldn't be starved so what's the loop's termination condition?
I'm not sure what the BEST way is, but here's something I might try:
Time-critical loop: runs in a Timed Loop structure. The Timed Loops give you better control and awareness of actual timing. Any data needed by normal priority fast loop should be written to a queue.
Normal priority fast loop: Dequeue data with a long (infinite?) timeout inside a standard While loop. This type of call will allow the thread to sleep while waiting for data to.show up in the queue. You shouldn't need additional "Wait" timing -- the queue helps you stay in sync.
Normal priority slow loop: standard While loop. If you use "Wait" timing, try to avoid waking up at the same time as the TC loop.
Another thought: when I did RT a few versions back, I used occurrences to synchronize various threads. At the end of the TC loop, an occurrence was set to wake up a data acq thread. After grabbing new data, an occurrence was set to wake the data processing thread. After that, another was set to wake the thread for generating new output signals. You get the idea. Each thread owned the CPU during the time slice when it was active. They weren't ever competing for it. This scheme was reliable at 1 kHz.
-Kevin P
09-12-2006 03:04 PM
Sounds like a dangerous (dead-lock prone) way to go about things.
Yes. I'm aware of this and I use a flat sequence structure in the time-critical loop to prevent this condition.
Lee Jay
09-12-2006 03:09 PM
I don't know what's causing the halt. The termination condition is not met for sure (actually, I can't even get that to stop because the loop stops executing - even abort doesn't stop it) but it doesn't run either. It doesn't look starved for CPU time since there's over 2000uS in each loop in which the time-critical loop is waiting (shown in the execution trace). The VI in which the while loop that stops responding exists continues to show that it's executing in the execution trace, but that's because it hasn't ended or been called again.
I don't think I can use any of the timed-event or related structures because the wait-until-next in the time critical loop is in a case structure that, in the other case, causes the system to be hardware clocked via a wait-on-IRQ from an FPGA. The same thing happens in that case (only one of my two normal-priority while loops keeps executing).
Lee Jay
09-12-2006 03:10 PM
09-12-2006 03:13 PM
That's possible. I've had trouble with memory-subsystem saturation in the controller due to RT's horrible memory management. Even when the loop is waiting, the memory controller must be horribly busy doing who-knows-what based on the testing I've done.
Lee Jay