Functional global set as reentrant vi in CLD sample?

In the CLD atm sample question attached. It set its functional global as a reentrant vi...
Now let me get this right , a non reentrant vi, no matter how many times it's called, stores its data into one location. So a functional global should be a nonreentrant vi so the functional global can SET the same data in the same place, and GET the same data in the same place.
Whereas a nonreentrant vi creates clones everytime it is called, and each clone stores a different set of data in a different place. So a functional global should not be a reentrant vi because it cannot retrieve the same copy of data; there are many different data sets stored in different places, the functional global would not know which data set to retrieve.
But how come this CLD sample set its functional global as reentrant vi and it works???
Attachments:
ATM Simulator LV86.zip ‏116 KB

richjoh wrote:
In your VI code "Shared clone is selected"
Below are past from the LV manual --
"Memory Usage - Only allocates clone VIs for the maximum number of simultaneous calls to the reentrant VI. Decreases memory usage..."
"Execution Speed - Creates clone VIs on demand. Slightly decreases execution speed and speed may vary per call.."
...and Preallocate is versa of above.
Yes the only reason to use Reentrant in any LV example is to keep separate copies in memory. This author uses the reentrant VI to track 3 different transaction in his example (looks like an banking ATM, I have not run it as yet). The author reentrant is for "deposit", "withdrawal" and "pin entry". Ctrl+F, the VI is used in 4 instances, one of them is to Get current action, the other 3 are Set.
IMHO, the example is overblown. Wonder how long it took the author to create it?
The reason it works is all access is sequential.
Overblown, yes. Reminds of the kid trying to show-off by climbing over the fence to pose next to the lion's cage. It will bite them eventually.
Keep It Simple Sir has clearly bee violated.
I will watch for someone who can explain WHY that was a good decision unless they felt there would 500 of these ATM GUIs running in parallel.
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction

Similar Messages

  • Functional Global Varibale is reentrant or not

    Please guide me, Functional global varible is reentrant or not.

    Just to muddy up the conversation...It depends!
    There are situations where you want to have a FGV be reentrant (preallocate clones).  Look at the Mean Pt-By-Pt VI.  It is a FGV that is set to reentrant.  This is done so that you can have multiple loops/signals performing means with the same VI and they keep their own data.
    But for the most part, FGVs should be set to nonreentrant for the sake of sharing data amonst you different loops and protecting the data.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Do I need to use a semaphore when reading/writing a functional global from reentrant VIs?

    I have a program that spawns multiple reentrant VIs running simultaneously.  These VIs write their status to a functional global.  The VI that monitors them periodically polls this global to check out how they're doing and takes action based on their collective status.  (BTW, I'll mention that this monitoring VI is NOT the parent that spawned the reentrants, just in case this might affect memory management as it pertains to my question.)
    Anyway, 90% of the time, stuff goes off without a hitch.  However, once in a while the whole thing hangs.  I'm wondering if there's any chance that I've overlooked something and that some kind of collision is occurring at the global.  If that's the case, then should I be setting a semaphore for the global read/writes?
    And, if this is a problem, then there is something deep about functional globals that I don't yet understand.  My notion of them is that they should negate the need for a semaphore, since there is only one global instance, which cannot be simultaneously called by the various reentrants.  Indeed, this is arguably THE WHOLE POINT about functional globals, is it not?  Or am I missing something?
    Thanks,
    Nick 
    "You keep using that word. I do not think it means what you think it means." - Inigo Montoya

    Thanks Uwe,
    This is a good hunch.  However, functional globals typically run at "subroutine" priority.  With this priority, it is not possible to select a specific execution system; it is always "same as caller."
    I will try your suggestion by switching to "time-critical" priority.  However, I do not know if this could lead to a different set of issues (non-determinism?).  It will probably take a little while to hear back from my guys on whether this makes a difference or not, because the error is sporadic, and sometimes doesn't come along for quite a while.
    While probing all of this, I looked at the execution settings for my reentrant VI.  It has standard settings: "normal" priority, running in the "same as caller" execution system.  My impression has always been that LV creates the clones with unique names.  This allows the clones to be in the same execution system with no problem, and the fact that the execution dialog allows me to choose "same as caller" for a reentrant VI supports this assertion.  This is logical, since there could potentially be many more clones than available execution systems.  "Preallocate clone for each instance" is selected, which is what I want, I think, though I don't know if it matters in my application.
    In summary, I am trying out your suggestion, but with skepticism.  Any other suggestions from anyone out there?  Any misunderstandings on my part that need clarification?
    Thanks,
    Nick 
    "You keep using that word. I do not think it means what you think it means." - Inigo Montoya

  • RT executable causes functional global variable VIs to become non-reentrant

    Hi,
    I am having a small issue with functional global variables (Repositories). The attached VI is a sample functional global variable I created that stores double precision numeric values. The VI properties are set to normal execution. I use this VI to pass data between loops running in real time on a PXI platform. When running my application from the project explorer (not creating executable) the VI functions as it should and passes data between my loops with no issues. But when I create a real time executable of my application and run it on the PXI, it does not share data between instances of the VI. My work around this issue is to change the VI properties execution priority to Subroutine but it forces me to modify my VI slightly for this to work (I have to remove the property node). I am not sure why this is happing. I have seen some applications with this VI that appear to function normally in development and in executable with the VI properties execution priority set to Normal. Any comments or suggestions are welcomed.
    I am running LabVIEW 2009, PXI-8186, and Windows XP
    Thanks
    Attachments:
    RT Repository DBL Numeric Command Ver 2.ctl ‏5 KB
    RT Repository DBL Numeric Element Ver 2.ctl ‏5 KB
    RT Repository DBL Numeric Ver 2.vi ‏25 KB

    Many properties require the front panel to be loaded in memory; the property you're using, NumItems, appears to be one of them (look at the help, you'll see that it says "Loads the front panel into memory.")  However, VIs running in an executable on RT do not have front panels, so those property nodes will not work.  If you were to log the error out terminal from the property node in your executable, you should see that an error occurs.  As a result, you're getting a 0 value out of the property node, causing your VI to output unexpected results.
    My recommendation is that you replace the property node with the function GetNumericInfo found in vi.lib\utility\VariantDataType.  It has an output called EnumNames.  Take the size of the EnumNames array and use that in place of the output from the property node.  This will work on RT.
    Note that this has nothing to do with re-entrancy, and the key hint is that the VI works when you remove the property node.

  • Functional Global Variable in the CLAD sample Exam

    Hello,
    A question in the CLAD sample exam #2 keeps puzzling me. It's question number 32 about FGVs:
    32. Which is not an important part of creating a Functional Global Variable?
    a. Using Shift Registers to store information
    b. Changing the VI’s execution settings to Reentrant
    c. Setting the VI to inline into calling VIs
    d. Setting the While Loop to stop after one iteration
    The answer given is the following
    32.Correct Answer: B
    Topic: Functional Global Variables
    Justification: It is not necessary to inline functional global variables into their calling VIs. In fact, inlining requires that the subVI be reentrant, which is forbidden for functional global variables.
    Clearly, for an FGV to work properly, the VI must NOT be reentrant. So I would have selected answer B, but the justification seems to clearly point to answer C as well, doesn't it? Is it a typo, a subtlety in the wording? I am stuck on this one!
    Solved!
    Go to Solution.

    Well, inlining requires reentrant.  Therefore, the best answer should technically be C.  This looks like one of those rejected/retired questions since it isn't quite right and/or left up to too much interpretation.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Multiple copies of functional global using vi references

    I have several producers aquiring data into a functional global (one functional global per producer). These functional globals are identical except for the name. Would it work to have only one functional global VI and obtain a separate reference for each producer? The matching consumer would also use the proper reference to consume the data.
    The functional global contains an array of the data which must be parsed by the consumer. It is possible that the array of data may not contain a complete set of data on a single "store" operation by the producer. The consumer, of course is written to check for a complete data record before completing processing on the record.
    Solved!
    Go to Solution.

    Les__Bartel wrote:
    tst wrote:
    Regardless of whether there is a better way, the answer to the question is yes. The FGV needs to be reentrant and the reference you open needs to be reentrant too and then you can use the CBR node to run the specific copy of the FGV.
    I thought a reentrant vi would not maintain the state of the uninitialized shift register from one call to the next.
    A reentrant VI will maintain the state of its uninitialized shift registers.  However, you need to be really careful how you do this.  First of all, you need to make sure it is set to Preallocate Clones.  What will happen in this situation is that each different place you call that subVI will each be a different clone.  This means that each call will have its own data.  The problem with this is that you can't share the data across multiple instances and therefore multiple loops.  If you don't believe me, go play with the Mean Point By Point VI.
    So what happens if you set it to shared clones?  A big freakin' mess.  You will have no control over which clone will be called where and there will be some major data corruption.
    This is why FGVs are almost always non-reentrant.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Functional global variable

    I would like to ask to the experts a question about functional global variables. 
    In the labview basics 2 course was said that a functional global variable is not reentrant. 
    My purpose is to implement a code in such a way.2 main vi's. The first vi deals with some hardware that writes data in an output file with 1 Hz rate (more or less 1Hz, I cannot decide it).
    The second vi deals with a different hardware (thermocouples). This works at a different rate (I cannot match exactly the different rates). I would like to write the data from the second hardware in the same output file of the first vi. 
    I am thinking to use a functional global variable to pass the information from the second vi to the first vi. In this way I am using the data from the thermocouples at a rate given by the first vi. But at the same time in the global variable the data are written at a rate given by the second vi.
    My question is: what exactly happens if the subvi (functional global variable) is called exactly at the same time? As you can understand it's not really important if I read the temperature with an error of 1 second, but I would not like the execution would stop or something like that. 
    A functional global variable is a subVI that is not reentrant. This means that when
    the subVI is called from multiple locations, the same copy of the subVI is used.
    Therefore, only one call to the subVI can occur at a time.functional global variable is a subVI that is not reentrant. This means that whenthe subVI is called from multiple locations, the same copy of the subVI is used.Therefore, only one call to the subVI can occur at a time.

    A couple of quick comments to add to this thread.
    FG's can be involved in Race Conditions if two callers attempt to direct set the same value. An Action Engine (well what do you expect?) can be coded to help with those situations.
    Example:
    In arecent app I needed to set the heaters to "0" if an over-pressure condition was detected. The Heater set points where driven by a PID. The safety conditions where controlled by a process monitoring the input values.
    So how do I keep the PID from setting the heater when the rig is not safe?
    A Safety AE !
    Actions used by the pressure monitoring set the Safety AE in an "go-safe" state where setting the heaters results in a null op.
    This particular pattern (two writters) screams for an AE to coordinate the vaious actions. Do this same thing with queues could get tricky.
    So for the Q in this thread we have a pattern of "two source of info, one sink for each" that screams for a queue.
    BTW:
    The AE Nugget linked above addresses what happens when two callers attempt to call the same non-re-entrant sub-VI.
    Have fun,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Is a functional global with loops inside case structure subject to race condition?

    Such as this one:
    Solved!
    Go to Solution.

    bmihura wrote:
    I'm being a bit dense here... would somebody write an example VI that demonstrates how functional global variables eliminate race conditions whereas a normal global variable would not? Or just describe it and I'll write the VI?
    The classic example used is a bank account.  Say you are making a deposit.  You have to read the current balance, add the deposit amount, and save the balance.  Now say you are making a withdrawal.  You have to read the current balance, subtract the withdrawal amount, and save the new balance.  Now let us say that both of these events happen at the same time.
    If you are using global variables, you read the global, perform the action, and save to the global.  But who reads what balance.  If both events read the balance at the same time, then whoever writes last will overwrite the other's action.  This is bad, especially if your deposit "didn't happen".
    Now using a FGV (or Action Engine), you can contain the critial parts of the code.  In this case the critical parts are the full read, act, and write.  So with the AE, you store the balance in a shift register.  You can perform whatever action you want inside of the AE VI.  Because the AE is not reentrant, only 1 action can be performed at a time.  So you make sure that deposit happens and is not overwritten by the withdrawal.
    Now for my caveat.  If all you do is a Get and Set inside of the FGV, it is basically a global variable, just slower.
    Read that acticle I linked to earlier and also read up on the Action Engine nugget.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • 1.5 How to globally set the System Cache location

    FROM ANOTHER USER ON ANOTHER BOARD:
    This one did not get answered completely.
    ************************* Question:
    Hello,
    I want to deploy JWS on a client PC with Microsoft XP OS. This client have multiple users. JWS put a file deployment.properties in the directory "documents and setting" for the current user.
    How can I create a uniquely file deployment.properties for all users of this client (new and existing profiles) ?
    Create a directory "documents and setting/all users/application data/sun/java/deployment/" with the file deployment.properties don't work.
    Create a directory "documents and setting/default user/application data/sun/java/deployment/" with the file deployment.properties is working but is not good for the existing users. This is good uniquely for new users.
    is there a solution ?
    King regards,
    funchung
    ************************* ANSWER:
    For windows, the system config file is at:
    {Windows Directory}\Sun\Java\Deployment\
    The value of the {Windows Directory} is determined by using the Win32 API GetWindowsDirectory.
    So for example, on XP, the system config file is:
    c:\WINDOWS\Sun\Java\Deployment\deployment.properties
    The settings in this system config file will be used by all users on the system.
    ***************************** HIS REPLY
    I've tried this and it doesn't seem to work.
    I've also tried createing a deployment.config file as per the http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/properties.html article and this doesn't work for me.
    Has anyone done this successfully??
    ******************************** MY REPLY:
    This is true.
    I can get the system install to work if I add the parameter:
    deployment.system.cachedir=C\:\\testcache
    to the deployment.properties file found under:
    C:\Documents and Settings\username\Application Data\Sun\Java\Deployment
    but it will NOT work by adding it to the:
    C:\WINDOWS\Sun\Java\Deployment
    directory. It just creates a new default one in the user's folder.
    What am I doing wrong?
    If there is not a way to globally set the System Cache location, then this isn't much better than the user cache for being able to "install" the software once on the PC and let any user that signs in access that application.
    We had high hopes for this, since this functionality was taken away from us once the java cache started being stored in the user's folders.
    More details:
    I just tried setting the mandatory=true setting and it tells me that it is not allowed to start because it can't find the
    deployment.properties in the same folder (full path is displayed) but I know it is there, because it is the same folder. I even double checked the spelling.
    Maybe there is a bug in the way it finds that properties file, or maybe I need to include something in that file that I didn't find in documentation?
    All it has in it is the one line:
    deployment.system.cachedir=C\:\\testcache
    Can anybody help shed light on this?
    It seems to be a bug that it can't find the deployment.properties file in the 'system' folder.
    -Chris

    I now found more on another thread:
    http://forum.java.sun.com/thread.jspa?messageID=3500778&#3500778
    You can close this one.
    Sorry.

  • Software timing - Functional Global?

    I was reading NI Intermediate manual to prepare for the CLD exam, and noticed that they used Functional global variable in combination with timed loop for the software timing. Also, the error handling was implemented using functional global.
    However, I was reading in one post( not this forum) that the functional global is obsolete, can anyone shed any light on this issue, why would the functional global be obsolete: and if it is, what are acceptable design for software timing.
    Thank you.

    Cory K wrote:
    I dont see why a global would be obsolete.
    There are some instances when using a global variable is the best option, especially in cases when a resource will be used on several different computers.
    A functional global variable isn't the same thing as a global variable. A functional global variable is what was used before global variables were introduced in LabVIEW 3. It is the heart of an Action Engine.
    As for their obsolesence... Hah! That's all I have to say on that.
    As to the original post:  I'm a tad suspicious. What kind of software timing and error handling is being done with a functional global variable? Can you post the code?

  • Functional Global Variable on Hold

    Hello everyone,
    I understood, by reading threads on the forum, that a call to a Functional Global Variable will block its execution if the FGV is already being accessed by another VI, correct? Is there any other way it would block, apart from the stated?
    The motive of the question is that I have one FGV (non-reentrant) that is read by 8 subVIs concurrently (they are, actualy, the same vi, but configured to reentrant) and whose access time varies, strangely, based on the number of subvis running.
    When less than 5 VIs are trying to access the FGV, the execution is blocked (I assumed it, because when the FGV is disabled and replaced by a constant there is no problem with the execution) and the access lasts at least 50 ms; if this number is between 5 and 8, the execution is done much faster. My first guess was that the FGV hasn't been initialized until the fifth subVi is called, but I don't know how to check that.
    I can figure that there is something wrong with the FGV, but can't put my finger on it. Any ideas?
    Thank you in advance for any help.
    Solved!
    Go to Solution.

    Thank you for your response, Ben
    I'll try to explaing the problem better with the images that follow.
    I have 8 concurrent instances of the "bitDefiner.vi" - shown below - in the program.
    It reads from the AE (a simple read-write one) and it's the only one to call it besides the writer (that generates the appropriate signal), gets the rising edge of a waveform and determines how long it takes until the falling edge, giving a category to this time later on. If it doesn't determine the period between rising and falling edge before the timeout runs out, it aborts the execution of the while loop. This VI execution is setup like this:
    That being said, let's go to the problem.
    Assuming there is nothing using the AE but one instance of the bitDefiner, it won't get the rising edge, due to the fact the signal is not being generated, resulting in a timeout. The return value on the diff indicator should be next to the one defined to timeout(image below)
    However, when the subvi concludes its execution, the diff indicator shows 54ms intead of 15ms; so I concluded that the AE is taking to long to process the call. Besides that, I'm quite positive that there is only one thread accessing the AE.
    After this result, I ran the other instances of the bitDefiner and after the 5th one got activated, the diff went to the expected 15 ms (I'm still thinking how to show that on picture).
    I tried highlighting the execution, but it didn't show me anything unsual. The call chain just present that the caller is the bitdefiner VI as expected.
    Any thoughts on that?

  • Functional global variable question

    Hello,
    I fully understand how a functional global variable (FGV) works and its purpose but I have one last question.
    How do I guarantee (or how is it guaranteed) that my sub-VI (the FGV one) is not re-entrant, in other words, how am I sure that when an instance of the FGV is running it does not loose the processor to others?  Is this an option that I can choose in a sub-VI or is it related to the while loop or case strucure that compose a FGV?
    Joao

    Hi Joao,
    For a little more background on configuring reentrancy and the options you have available if you do want to make a subVI reentrant:
    LabVIEW Help: Reentrancy: Allowing Simultaneous Calls to the Same SubVI
    http://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/reentrancy/
    As Lynn said, all new SubVIs will be non-reentrant by default.
    Regards,
    Tom L.

  • Function global variable(FGV) template

    Hi All 
    if NI adds the Fuctional Global Variable (FGV) tempalte in design pateren tempates in hte New window, it is easy to create FGV VI's.
    and Helps the programmers, no need to create from the begining of VI.
    Even it is usefull for CLD Exam also.

    Something like this? Note that I would use the term "Action Engine" instead of "Functional Global Variable" specifically to discourage the use of this template as a global variable and instead emphasize its role as an action performer on centralized data (as noted in the comments).

  • Functional global reach

    Hi all.
    Have Main app and 4 sub-apps.  Each of the 4 sub-apps has functional global (or action engine) to which it writes and reads a cluster of app specific data.
    The idea was that using a functional global for each app then data could be passed between them all and the Main app.
    For example, I want to be able to drop the FG of sub-app1 on the BD of sub-app2 and read the cluster of data.  At the same time sub-app1 would be updating its FG on its own BD.
    This does not seem to be working.  For example the FG1 is being updated by sub-app1 BUT the instance of FG1 on the sub-app2 BD is empty.
    None of the FG's is reentrant; therefore there should only ever be one instance of each FG, correct?  There is only one(1) instance of each FG on disk.  Each sub-app and FG is located in a separate LV Project.
    Confused.
    Battler.
    Solved!
    Go to Solution.

    MarcoMauri wrote:
    I may be wrong but since the FG is running in different projects, i.e. different application instances, it cannot be used to exchange data.
    In any case that are other way to do this, for example DataSocket....
    Marco
    I believe you are correct.
    While both VIs are running in the two project go to the hiarchy screen and hit "ctrl-a" to show all.
    You will see that the two FG are running is unique contexts. So this is the equivelent of one app talking to anothe app on the same machine or across PCs, so Datasockets, TCP/IP, VI server...
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Functional globals - LVOOP

    Couldn't using functional globals be considered similar to OOP?
    After all, they could be considered objects that have their own data sets.

    WayneS1324 wrote:
    Couldn't using functional globals be considered similar to OOP?
    After all, they could be considered objects that have their own data sets.
    As a self-taught OOPer, yes I agree. I suspect some formall OOPer may think otherwise.
    I think it wasw Dr. Shane o'neal that taught me that Action Engines are actually something called "Componenet Orieneted Programming" rather than Object Oriented.
    Setting the technical hair-splitting to the side for now...
    I think of AEs and LVOOP apps as being one version being the other version turned inside out.
    In a an AE the data is inside the AE.
    In LVOOP the data (normally stored in a SR) is outside.
    Although the AEs are easier to understand develop and support the LVOOP versions have some benefits that are mostly focused around the feature that changes to one class don't always require updates and re-testing of others. If none of the Vis (methods) in a calss don't get updated they do not re-tested. In an equivalent AE implementation, changing a action (method) results in the VI being resaved so the whole critter needs re-certified.
    So there are many parallels and working with one approach can help understand the other.
    Done rambling,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • Not able to load jspx file from the classpath in Integrated OC4J

    Hi, I am using integrated OC4J from my jdeveloper to deploy my application as an ear file. It contains one jar file (with ejb deployment desscriptors) and a war file (including Model and Viewcontroller project contents). The war file contails a jspx

  • Exception caught while loading slideshow.xml "object error

    Got this error after making a slide show in Fireworks, bringing it into dreamweaver cs3. Works great in firefox, but of course i get this error trying it on a pc with IE7. Any ideas? <AlbumBook ver='1.5' title='' description='' firstAlbum='0' width='

  • My message for sony

    don't abonden the tablet s1 if you do will asume the same for future tablets and mobiles. tablet s1has the same isseus as the xperia tablet s. second of all stop being so silent many people waiting for news going totally nuts, silence equals no updat

  • Error while reversing the PGI

    Hi All, We got the following error message while reversing the PGI. " Goods issue for the delivery 123456 cannot be cancelled for the following reasons. Deficit of Customer stock unr. 2 EA : Material  Plant  V ".   Message No : M7021. pease help on t

  • Contact software like Palm for Blackberry Curve?

    I have been a Palm user for years. I now have a Blackberry Curve and want a contact type tool similiar to Palms. I want to be able to pull up a contact and see all the data in a better format than what is available on the blackberry today. Are there