HChandler Posted August 1, 2007 Report Share Posted August 1, 2007 Hi, I Have questions about the reentrant property. From what I gather, the normal behavior for vi's is that the data stored in them is "saved" between different calls to a non-reentrant vi, even though the vi might called in several different places in a given vi. Also, since for the default, non-reentrant mode, there is a single instance of this vi, and so subsequent calls to the same vi have to wait for completion of previous calls. Yes? I have a bunch more questions. If I call a non-reentrant vi from several different places within the same vi, only a single instance of this vi is created, with a single name space and program code space (correct?) , but when the re-entrant property is set, each iteration of the same vi spawns a new process, allocates new memory for variable storage and program code? Do all of these code instances persist throughout the life of the vi? Can they be freed without closing or leaving the vi in which they were created? Say I have a vi called nonReentrant.vi. If subVIa calls nonReentrant.vi and another vi, say subVIb calls nonReentrant, are both re-using the same code space, or to they each have their own instance of nonReentrant? On completion of either subvi does nonReentrant persist. If not is there a way to make it persistent? If so, is there a way to free it after you're done using it. Is there a way to make a vi conditionally reentrant? I'll probably have more questions after these are answered. Thanks for your patience Quote Link to comment
TG Posted August 1, 2007 Report Share Posted August 1, 2007 QUOTE(HChandler @ Jul 31 2007, 04:29 PM) Hi, From what I gather, the normal behavior for vi's is that the data stored in them is "saved" between different calls to a non-reentrant vi, even though the vi might called in several different places in a given vi. Also, since for the default, non-reentrant mode, there is a single instance of this vi, and so subsequent calls to the same vi have to wait for completion of previous calls. Yes? Correct. Data stored in a static (non reentrant) VI is static. The VI has a single existance and as such there is an implied semaphore mechanism in static VI's in that only one call at a time can be made to it. QUOTE(HChandler @ Jul 31 2007, 04:29 PM) If I call a non-reentrant vi from several different places within the same vi, only a single instance of this vi is created, with a single name space and program code space (correct?) , but when the re-entrant property is set, each iteration of the same vi spawns a new process, allocates new memory for variable storage and program code? Correct except it is based on what you drop on the block diagram. I believe the instances already exist before run time. However if you use VI server to spawn the VI using reentrant option then I (think) a clone is created. Quote Link to comment
xtal Posted August 1, 2007 Report Share Posted August 1, 2007 Think of a VI as having four pieces in memory at one time - front panel, block diagram, data space, and compiled code. So a normal VI that is non-reentrant will use the same of each of these chunks of memory each time it is called. What reentrancy gives you is a separate data space for each call, or instance, of that subVI. So if you are storing data inside non-initialized shift registers, you get a clean buffer for each subVI call. The code, front panel, and block diagram will be the same, so the subVI calls don't happen at the same time, they are sharing the same memory for each of the other pieces. However, things are a little trickier if you are debugging reentrant subVIs because you can get copies of each front panel when you open them. I'm going to stop now and see if this helps you understand the concept better. Reentrancy is a complicated topic, so please keep asking questions as you experiment. Quote Link to comment
TG Posted August 1, 2007 Report Share Posted August 1, 2007 QUOTE(HChandler @ Jul 31 2007, 04:29 PM) Do all of these code instances persist throughout the life of the vi? Can they be freed without closing or leaving the vi in which they were created? I think there is a way but VI server has to be used and the reentrant Vi will be a clone. Pass the Vi reference to the clone and have it destroy itself when its done doing its job. I believe the instances persist until the VI that created it quits but I may be wrong about this. Quote Link to comment
HChandler Posted August 1, 2007 Author Report Share Posted August 1, 2007 QUOTE(xtaldaz @ Jul 31 2007, 11:46 AM) Think of a VI as having four pieces in memory at one time - SNIP- The code, front panel, and block diagram will be the same, so the subVI calls don't happen at the same time, they are sharing the same memory for each of the other pieces. OK so lets say I have a sub-vi that is used to poll multiple devices. Because of the peculiarities of bus arbitration, there are long latencies in accessing these devices. What if it is desired that several devices be queried in parallel using the same vi. Say my vi has has an input control node to direct inquiries to different buses and/or devices. Do they still have to wait for completion? Can this behavior be changed either modally or programmatically? Thanks Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.