Semaphores and queue together. Is it necessary?

Hello.
I am using a State Machine driven by queue, using a For Loop to enqueue three States that have to be executed in sequence. The code is working fine but when I run it in Highlight Mode is possible to see that the "State 1" of the State Machine start running while the For Loop (which enqueue the elements) is still running. Is this kind of code safe?
I mean, for this example everything is working fine, but if I have SubVIs running in the States of the State Machine, would not be safer to have the For Loop execution done, before start playing with the SubVIs of the State Machine? Would a semaphore help me with that? I found this thread that discussed similar things, but I still thing that would be safer to have the For Loop done and just after that start running the State Machine.
What do you thing guys?
Thanks
Dan07
Message Edited by dan07 on 04-17-2010 02:59 AM
Attachments:
Enqueue.vi ‏16 KB

Good question dan!
The code you are explaining is "SAFE".  and seems like a good implementation of a basic "Producer-comsumer archetecture"  Your UI stays responsive while the consumer loop does all the data manipilations.  A very positive point.
I am a bit concerned about scaleability of the code since you have added a programatic "flush queue" in the consumer loop.  It does what you want today but, what if you add a state that enters from another event?  the flush queue tosses that element out too.  and you might really want to do what the operator asked.  I would do the time check in the producer loop (not much code to slow things down - just a timer call and a comparison right?) and determine if its correct to queue up the time based state(s).
Then again- I'm struck with the need for a time enabled state-  will the operator expect the code to behave differently at different times?   It is possible but, questionable. 
By-the way.
you can exit the consumer loop based on the error out of the dequeue element.  it returns when the queue is destroyed or when there is an element.
Message Edited by Jeff Bohrer on 04-17-2010 03:39 PM
Message Edited by Jeff Bohrer on 04-17-2010 03:41 PM
Jeff

Similar Messages

  • When do VI and queue references become invalid?

    Hi all,
    I have a fairly complicated problem, so please bear with me.
    1)  I have a reentrant SubVI (let's call it VI "Assign") that has an input cluster of (VI ref, queue ref) (let's call the cluster type "Refs").  If the VI ref is invalid (first execution), the VI ref and queue ref are assigned values and are passed on as an output cluster of same type.  (The VI does other things too, but for simplicity only this is important.)
    2)  The VI that calls VI "Assign" (let's call it VI "Store") is not reentrant and has a local variable of type "Refs" that is wired to the input and output of VI "Assign".  This VI effectively stores the references.  The references returned by VI "Assign" are always valid right after the call, but after the problem condition described below, they are invalid at the start of all calls before they are passed to VI "Assign".
    3)  VI "Store" is called by multiple non-reentrant VIs, so the local variables of VI "Assign" retain their values (Has been tested and verified to retain their values).  The VI causing the problem in this case is a template VI of which multiple copies are launched (let's call it VI "Template").
    The problem is that the moment an instance of VI "Template" is closed, the queue reference becomes invalid, although the actual variant value of the reference remains the same.  The VI ref can become invalid or not, depending on small changes, but is always reproducible.  I assume there must be some similarity between VI and queue refs.  After spending some time researching, the Labview help states for the Open VI Ref component "If you do not close this reference, it closes automatically after the top-level VI associated with this function executes."  In this case I assumed it means that the moment the reentrant VI "Assign" finishes, the references will get cleared ??  So I made a non-reentrant VI (let's call it VI "NR Assign") that only assigns values to the references and VI "Assign" now calls this VI (It effectively does what I described VI "Assign" does).  I keep this VI alive by using it in a VI which never terminates and since it never terminates, the references should never become invalid.  Anyone still following?  This didn't solve the problem though.  If I reproduce the same scenario using only one instance of the template VI, it works just fine.  Furthermore, the VI and queue references are never closed, to aid analysis of the problem.  Can anyone shine some light on what happens when a template VI terminates?  Could this be the problem?
    Unfortunately I cannot include the code.
    Thank you whoever is able to make sense of this.
    Christie

    Christie wrote:
    Hi all,
    I have a fairly complicated problem, so please bear with me.
    1)  I have a reentrant SubVI (let's call it VI "Assign") that has an input cluster of (VI ref, queue ref) (let's call the cluster type "Refs").  If the VI ref is invalid (first execution), the VI ref and queue ref are assigned values and are passed on as an output cluster of same type.  (The VI does other things too, but for simplicity only this is important.)
    2)  The VI that calls VI "Assign" (let's call it VI "Store") is not reentrant and has a local variable of type "Refs" that is wired to the input and output of VI "Assign".  This VI effectively stores the references.  The references returned by VI "Assign" are always valid right after the call, but after the problem condition described below, they are invalid at the start of all calls before they are passed to VI "Assign".
    3)  VI "Store" is called by multiple non-reentrant VIs, so the local variables of VI "Assign" retain their values (Has been tested and verified to retain their values).  The VI causing the problem in this case is a template VI of which multiple copies are launched (let's call it VI "Template").
    The problem is that the moment an instance of VI "Template" is closed, the queue reference becomes invalid, although the actual variant value of the reference remains the same.  The VI ref can become invalid or not, depending on small changes, but is always reproducible.  I assume there must be some similarity between VI and queue refs.  After spending some time researching, the Labview help states for the Open VI Ref component "If you do not close this reference, it closes automatically after the top-level VI associated with this function executes."  In this case I assumed it means that the moment the reentrant VI "Assign" finishes, the references will get cleared ??  So I made a non-reentrant VI (let's call it VI "NR Assign") that only assigns values to the references and VI "Assign" now calls this VI (It effectively does what I described VI "Assign" does).  I keep this VI alive by using it in a VI which never terminates and since it never terminates, the references should never become invalid.  Anyone still following?  This didn't solve the problem though.  If I reproduce the same scenario using only one instance of the template VI, it works just fine.  Furthermore, the VI and queue references are never closed, to aid analysis of the problem.  Can anyone shine some light on what happens when a template VI terminates?  Could this be the problem?
    Unfortunately I cannot include the code.
    Thank you whoever is able to make sense of this.
    Christie
    All LabVIEW refnums do get deallocated automatically when the top-level VI in whose hierarchy the refnum was created goes idle (stops executing). You will have to make sure that the creation of a refnum is done inside a VI hierarchy that stays running for the entire time you want to use that refnum.
    Rolf Kalbermatter
    Message Edited by rolfk on 06-27-2007 11:52 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • I can't open pages files from USB and iCloud due to : "The necessary file index.xml is missing".

    I can't open pages files from USB and iCloud due to : "The necessary file index.xml is missing". Original file is written on iMac (2014) and saved to an USB stick and then transferred till macBook Pro (2009, Yosemite) for editing. Then I shared the files by iCloud but I am not able to open them on iMac again. Niether can I use the USB stick to transfer the edited files back. I'm running Pages '09 4,1 (923) on the macBook and Pges 5.5.2 (2120) on the iMac.
    Håkan

    Pages 5.5.2 is extremely incompatible with even other Macs let alone the vast majority of PC and MsWord users out there, so not a good idea to leap into the fire with both eyes shut.
    After having done that to the first Pages 5 files, Apple has repeatedly done it to even the most minor point updates. Apple can't even anticipate its own erratic changes let alone what everyone else needs doing.
    Peter

  • How do I back up my itunes to an external hard drive and restore from same if necessary

    How do I back up my entire itunes to an external hard drive and restore from same if necessary.
    Thanks

    This is where iTunes stores backups for different operating systems: http://support.apple.com/kb/HT4946
    I do not use a Windows machine, have a Windows Vista Dell I rarely startup now.  But, from what I remember with Win boxes is, you will have to create on the external hard drive a file system like that one iTunes normally uses, and then in the iTunes preferences or control panel edit the location for the storage to specify the name of the external hard drive, or its letter code, with the name of that file system you created on the exernal drive.
    I would also move all of the files from the internal file system to the external since you have now told iTunes that is where they are...before deleting from the internal drive, test iTunes to see that it goes where you want it to go.

  • Can I run Apple TV 1 and 2 together on the same iTunes account and on the same tv with two hdmi slots?

    Can I run Apple TV 1 and 2 together on the same iTunes account and on the same tv with two hdmi slots?

    Yes.
    Captfred

  • I have a ipod shuffle synced to a desktop (ver 9), I have a new laptop and downloaded itunes (ver 10.7).  When i plug the ipod in the new laptop it wants to delete my songs. How do i use my new alptop and ipod together?

    I have a ipod shuffle synced to a desktop (ver 9), I have a new laptop and downloaded itunes (ver 10.7).  When i plug the ipod in the new laptop it wants to delete my songs. How do i use my new alptop and ipod together?

    Your iPod is designed to sync with only one iTunes library at a time.  It will recognize the iTunes library on the PC as a new library.  If you sync the iPod with this new library, all content will be erased from the iPod and replaced with what is in the new library.  So what you will want to do is copy everything from the iPod to your new iTunes library on your PC first.
    See this excellent user tip from another forum member turingtest2 outlining the different methods and software available to help you copy content from your iPod back to your PC and into iTunes.
    Recovering your iTunes library from your iPod or iOS device
    B-rock

  • HT1277 I have changed my email account on my computer to imap and 993 but now I'm not receiving any emails. I was originally trying to sinc my ipad and iphone and computer together so when I delete an email it will all delete together. What is the best wa

    I need help to update my email and also to sinc my computer, iphone and ipad together so when I delete my emails they will all disappear together. I got the iphone and ipad to work but cant seem to get the computer to work.

    E-mail provider?
    Troubleshooting sending and receiving email messages

  • How can I run a vga monitor and projector together on my Mac Pro 15"??

    How can I run a vga monitor and projector together on my Mac Pro OSX 15"?

    You can upgrade to Snow Leopard, Lion or Mountain Lion (coming next month), but you need Snow Leopard to upgrade to Lion or Mountain Lion. Check this web to know how to add memory to your computer and the memory that it supports (probably, 3 GB).

  • How can I create a client console and work together with the Cache Server?

    How can I edit the following Cache-Server.cmd file to create a client console and work together with the Cache Server?
    The following is the cache server file: contacts-cache-server.cmd
    @echo off
    setlocal
    if (%COHERENCE_HOME%)==() (
    set COHERENCE_HOME=c:\coherence
    set CONFIG=C:\home\oracle\coherence\Contacts
    set COH_OPTS=%COH_OPTS% -server -cp %COHERENCE_HOME%\lib\coherence.jar;C:\home\oracle\
    coherence\Contacts;C:\home\oracle\coherence\Contacts\classes;
    set COH_OPTS=%COH_OPTS% -Dtangosol.coherence.cacheconfig=%CONFIG%\contacts-cache-config.xml
    java %COH_OPTS% -Xms1g -Xmx1g -Xloggc: com.tangosol.net.DefaultCacheServer %2 %3 %4 %5 %6 %7
    :exitEdited by: junez on 23-Oct-2009 09:20

    Hi
    To run the console, change DefaultCacheServer to CacheFactory
    Paul

  • TS4006 Hi I am having trouble updating my apps I have tried one at a time and all together but they just will not load any ideas would be appreciated

    Hi, I am having trouble updating my apps, I have tried one at time and all together but they just keep on whirring away and nothing happens! any ideas woud be appreciated.

    Suggest you update all these apps on iTune (computer) and sync them to your iPad.

  • Monitoring of remote system's Transactional RFC and Queued RFC

    Hello,
    In our production system, in rz20- CCMS monitor templates- Communication-Transactional RFC and Queued RFc- outbound queues- Queues otherwise not monitored we can see blocked queues for each client.
    System is connected to solution manager and we wish the central auto reaction is implemented in solution manager
    However i am unable to find Transactional RFC and Queued RFC for the remote system, they exist only for solution manager itself
    Tell me how can i do the central monitoring

    Hello,
    First you need to check with your Landscape in solman in order to monitor any kind of activities to do so pls follow these steps.
    Go to SMSY in solman under Landscape components>Product systemsselect you satellite system example SAP ECC.
    On the main screen you will find client for which you have generated RFC connection. Please check though connection are working fine, Go to edit mode and try to click on generate button there will be a pop-up, which gives a clear picture of RFC connection which already exists, and you can also re-generate this RFC connection by clean it up when you re-generate pls select under Actions after generation assign RFC dest for system monitoring.
    But make sure there is no project impact on this RFC, like they are not using any logical components and already have some projects running on this RFC connection.
    I would advise you to first you the option of assign and check RFC button which is next to generate icon.
    Regards
    JUDE

  • Have been advised by my email provider (recently blocked account requiring password reset) that they will only reset the password after a proven anti viru and malware scan has been done on ipad and iphone. Is this necessary and if so what do i use

    Have been advised by my email provider (recently blocked account requiring password reset) that they will only reset the password after a proven anti virus and malware scan has been done on ipad and iphone. Is this necessary and if so what do i use

    As KP has pointed out, there actually aren't any anti-virus programs in the App Store. There are a few that allow you to scan e-mail or stuff like that, and a few that provide you with information about malware and new threats for other systems. But none are available that can scan your iOS device for malware, because the security restrictions in iOS do not permit any apps to have that kind of access to anything. Which means that you also cannot be infected with a virus (unless you have jailbroken your device).
    If your account got compromised, that had nothing whatsoever to do with your iPad. Someone simply hacked it remotely. Happens all the time. It's really amazing that, in this day and age, e-mail providers are so ignorant of technology and how their own systems get compromised that they would try to require you to run software that does not exist!

  • TA48312 I NEED TO UPGRADE FROM 10.5.8 TO USE MY ITUNES MATCH, WHAT DO I NEED TO DO TO DO THIS?  I HAVE PAID FOR IT AND HAVE DONE ALL THE NECESSARY TASKS TO GET ICLOUD UP BUT MY ITUNES WILL NOT WORK?

    I NEED TO UPGRADE FROM 10.5.8 TO USE MY ITUNES MATCH, WHAT DO I NEED TO DO TO DO THIS?  I HAVE PAID FOR IT AND HAVE DONE ALL THE NECESSARY TASKS TO GET ICLOUD UP BUT MY ITUNES WILL NOT WORK?

    jbrie8210 wrote:
    I NEED TO UPGRADE FROM 10.5.8 ...
    The first step in Upgrading... is to Snow Leopard = OS X 10.6.x
    It is Not available as a download... It is a Paid Upgrade.
    Do this first...
    Check that your Mac meets the System Requirements for Snow Leopard...
    Snow Leopard Tech Specs
    http://support.apple.com/kb/SP575
    If so... Purchase a Snow Leopard Install Disc...
    http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard
    Other countries...
    http://support.apple.com/kb/HE57
    After the Successful Install, run Software Update to get the latest updates for Snow Leopard.
    Be sure to make a Backup of your Current System Before Upgrading...
    Next...
    Upgrade to Mountain Lion
    With Regard to ML...  Check here for compatibility of 3rd party Software you may be using... Also note that Rosetta is no longer supported in Lion and Mountain Lion...
    http://roaringapps.com/apps:table
    You should also consider more RAM... Get the Maximum you can for your Mac...
    It is important to get the Correct and Matching RAM
    See Here  >  OWC RAM  >  http://www.macsales.com
    The above site also has videos on how to Install RAM should you need it...

  • How to use external hard drive and iTunes together?

    how to use external hard drive and iTunes together?

    Yes I did get to that part.... I went trough external to retrive itunes folder... When I selected the folder, it said that it was locked, choose another folder... I then went to my external again to my itunes folder and and used command I to see if folder was locked and it wasn't.... it was suggested on another forum to reboot.. which I did and still same problem... All I want to do is link my external hard drive that has my itunes playlist from another Mac to my new one.. and to also use the external as the main source for adding new songs to my playlist...

  • What is required in the HOST and QUEUE field when ...

    Hi
    When setting up my printer, i fill the options identical to what follows:
    PRINTER:  SAMSUNG HOME
    DRIVER:    GENERAL
    BEARER:  LPR <-----------------------------( NOT SURE IF IT IS THE CORRECT OPTION TO SELECT )
    The following fields appear once LPR is selected:
    ACCES POINT : HOME
    HOST:              WHAT COMES HERE?
    USER:              SKY00BER
    QUEUE:            WHAT COMES HERE?
    ORIENTATION: PORTRAIT
    PAPER SIZE: A4
     if it helps, my printer is SAMSUNG CLX-3175FW. It is Wifi Enable and is connected to my HOME acces point.
    please do correct me if there has to be changes to the BEARER or anything else.
    i could really use some help.
    thanks in advanced.

    sky00ber wrote:
     Hi,
    What is required in the HOST and QUEUE field when setting a WIFI printer?
    When setting up my printer, i fill the options identical to what follows:
    PRINTER:  SAMSUNG HOME
    DRIVER:    GENERAL
    BEARER:  LPR <-----------------------------( NOT SURE IF IT IS THE CORRECT OPTION TO SELECT )
    The following fields appear once LPR is selected:
    ACCES POINT : HOME
    HOST:              WHAT COMES HERE?
    USER:              SKY00BER
    QUEUE:            WHAT COMES HERE?
    ORIENTATION: PORTRAIT
    PAPER SIZE: A4
     if it helps, my printer is SAMSUNG CLX-3175FW. It is Wifi Enable and is connected to my HOME acces point.
    please do correct me if there has to be changes to the BEARER or anything else.
    HELP URGENTLY NEEDED!
    I'm not sure but I give it a try.Turn your security(WPA/WEP) and Firewall temporarely off. HOST is the IP address of the printer. QUEUE can be YES or a specific amount of prints, like 1,2,3......
    If I look at the manual of your printer I see that you can find the IP and MAC addresses in the Network Configuration Report.I don't know what the USER is doing there because if there is a user then there must be a password.
    ‡Thank you for hitting the Blue/Green Star button‡
    N8-00 RM 596 V:111.030.0609; E71-1(05) RM 346 V: 500.21.009

Maybe you are looking for

  • Pie chart legend showing digit "1" when we set "ignore blank cells"property

    All, We have pie chart in Xcelsius 2008 that shows the data with legend value and we have also set the ignore blank cells property to ignore the blank value from column. but once we set this property, it displays the digit "1" in the legend when ther

  • TDS problen at the time of F-54

    Dear, we are facing the problem at the time of clear vebdor down payment (F-54), System is not reversing the TDS amount in F-54. Here Advance amount is less then Invoice amount. Entries as Below. At the time of invoice : 001 40  9000 453020     Prof.

  • Chinese characters display

    I want to store corresponding chinese words for few labels inside the global variables (.txt) file and want to display it inside JSP. Do i need to take any precautions for this ? Or like normal variable i can make use of that ? regards Manisha

  • No internet anymore

    I had a dynamic ip address. I was able to access the internet. With my one desktop and one Xserve network. I just got a static ip address for my Xserve. As soon as I configured my Xserve with the static IP address. I lost all access to the internet w

  • Updating Flash Produces Message that the Update is Not as New as the Installed Version

    On certain computers, every time I update Flash Player, I get a message (twice) that says that the already installed version is newer (higher number) than that which I am trying to install. Clearly, that is not true. It appears that the installation,