What is a good way to use the queues for the model of consumers/producers?

Hi all

I am following the model of consumers/producers to use the queue to synchronize the following process: the producer is a loop to produce a number N, I will put each number generated in a table and after each 5 numbers generated, I put the table in the queue and pass it on to the consumer. I have to wait the use by consumers of the data and it will then remove the item from queue so that producers will have the chance to produce another 5 numbers. As I put the maximum size of the queue one, I expect that the producer and the consumer turns to produce / consume all five numbers and the opportunity to another. Here is my code

When the checkbox is false, the code will be

For the first 5 numbers, product will generate every thing right and put it in the table, and it's going to pass the array to the quere so that the consumer will have the chance to loop through the table. I except the procude loop will continue only when the queue is available (i.e. all items are deleted), but it seems that once the consumer starts the loop loop of the product will continue (if the indicator x + 1 and x 2 will be changed to numbers). But this isn't what I want, I know there must be something wrong, but I can't say it is.

Advertisement

dragondriver wrote:

As you say in 1, sequency structure to enforce the order of execution, that's why I put it here, in this example, the simple question, I replace the complete code with increase in the number, in the real case, the first markers + 1 and + 2 must be performed in this order.

Mikeporter says:
1. get rid of all the structures of the sequence. None of them are nothing but apply a work order which would have been the same without them.

So even if you delete the sequence structure, there will be a fixed & defined order and it is because LabVIEW follows the MODEL of FLOW OF DATA.

Data flow model (more precisely in the context of LabVIEW): a block diagram node runs when it receives the required inputs. When a node is running, it produces output data and transmits data to the next node in the path of the data stream. The flow of data on the nodes determines the order of execution of the VIs and functions on the block diagram (click here for reference).

Now in your code, just remove the sequence structure will not make you order will be going to stay the same, but you need to do some very minor changes (as thread of the error in loop, before that he go to the node "Élément Dequeue").

Come to the main point: it's a good way to use the queue for the consumer/pmodel that?
The model you are using (and qualifying as consumer/pmodel) is much too deviated from the original consumer/pmodel which model.

dragondriver wrote:

For the second, Yes, it's my fault for delete, though. I'm actually the example of model of producer/consumer design pattern, but I do not pay attention to the while loop in the part of the consumer.

While loops (two producers & consumers) are the essential part of this architecture and cannot be deleted. You can start your code using standard model.

Tags: NI Software

Similar Questions

  • Good way to use the concurrent data store

    Hello

    I'm developing a multithreaded C++ application that uses the C++ of Berkeley DB Library.

    In my case, I have several databases that I composed in a wooded area. It is important for me to use an environment because I need control over the cachesize parameter.

    I don't need no guarantee of transaction and have for most of the readings, so I decided to use the "simultaneous database.

    I first pre-fill all databases with a number of entries (configuration single-threaded phase) and then work on it at the same time (for most readings, but also insertions and deletions).

    I tried all kinds of different configurations, but I can't work without specifying DB_THREAD as a flag of the environment.

    I don't want to because then access all handles is synchronized sequentially according to the documentation:

    "... Note that the activation of this indicator will serialize calls to DB using the handle between the threads. If

    simultaneous scaling is important for your application, we recommend handles separate for each thread opening

    (and do not specify this indicator), rather than share handles between threads. "

    (Berkeley DB QAnywhere C++)

    So I tried to open the environment with the following indicators:

    DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL | DB_INIT_CDB

    All data in this environment handles are open only with the DB_CREATE flag.

    So, since my understanding this same basic access handles need to be synchronized, I opened separate handles foreach database for each thread (opening the handles is still single-threaded).

    In my first approach, I have only made use of the object of global environment. Which does not work and gives the following during operations error message:

    DB_LOCK-> lock_put: Lock is no longer valid

    So I thought, since the same handle global env is passed to all handles separate DB, it is perhaps a race condition critical on the handful of approx.

    So in my next test, I opened also handles separate EPS in each thread (and db handles owned each).

    That does not produce an error in db, but now it seems that each thread sees its own version of the databases (I call it stat early in the life of each thread and he sees all of the empty dbs).

    What is the right way to use the concurrent data store? Each thread should really open his own set of db handles? What about the number of open handles env?

    PS: Without specifying that the DB_PRIVATE flag seems to do the job, but for performance reasons, I want all operations to perform in the cache and do not specify product DB_PRIVATE average of several writes to the disk for my scenario.

    Thanks a lot for your help.

    CD (simultaneous database) allows a single editor with multiple drives, access to the db at a given point in time.    The handle for the writer doesn't have to be shared with readers.   If you share the DB handle then calls are synchronized, but if each thread has its own handle DB then this is not the case.     Since you have an environment, DB_THREAD must be at the level of the environment.   This will allow the sharing of the environment handle.     This type of error "DB_LOCK-> lock_put: Lock is no longer valid" you can provide us your code so we can take a look.   Also what BDB version are you using?

  • What is a good way to determine the validity of the GPS with BPS?

    Hello

    I use bps for a native application on the Playbook. There are a lot of functions to call to get information about the events of geolocation, which is great. But I'm looking to distill information into something that could tell me if yes or no position (lon, lat at least) is designed to use in my application... it is to tell whether or not I am a "GPS coordinates". You can check the validity of all to a large number of parameters (altitude, heading, speed, etc.) ... but nothing that tells you if lon and lat are valid.

    Does anyone have advice as to how I can a true/false 'gpsIsValid' extracts the available data?

    REF;

    http://developer.BlackBerry.com/native/reference/PlayBook/com.QNX.doc.bps.lib_ref/com.QNX.doc.bps.Li...

    If you get a reading at all, it should be "valid" in the sense that it came from calculated data based on the satellites used.

    What you need to do is to decide 'how' it is valid, that's up to you: https://developer.blackberry.com/native/reference/playbook/com.qnx.doc.bps.lib_ref/com.qnx.doc.bps.l...

  • What is the best way to use the Y50-70 battery please?

    I bought the laptop y50-70

    but I want to know what is the best method to use the battery.

    and the best way to recharge.

    NOTE *.

    IAM always use the cable and I gave the battery except a few times.

    Thank you very much..

    Best way to use the battery, if your laptop should ALWAYS be connected in-

    Go to eat energy Lenovo - should be a RED icon in the system tray - and choose the mode for a better health of the battery (or battery Protection or health of battery optimized mode).

    I don't know what the energy Manager version you have, but the option must seem similar. What it does is, it will keep your battery charged ONLY up to 60 percent and will increase its service life.

  • Where is the way to use the Airbrush tool like an airbrush tool?

    Hello. If I could understand the intuitive way to use the airbrush CS6 tool for photoshop I wouldn't be here.

    Yes, I miss my new mac system with my own software and how easy it is the applications work.

    Trying to figure out how to use the tool airbrush CS6 make me wonder about all these decades in the industry of graphic arts where I could use photoshop.

    I'm NOT a newbie to computers and adobe applications. However, that said, they always do their best to confuse me and let me do my work.

    I am about the evacuation? So what...

    Then like a seasoned Photoshop cs6 veteran, before I am now reduced to begging for an answer of how to do a single airbrush on the photo application that I used to do

    After about three minutes, and "outta there". to spend an hour and not being able to accumulate layers of color fade on the lettering in photoshop.

    (you can cut as many you want)

    How you you will find a tool that is not in the toolbar, the Airbrush tool?

    How do you get to the layer of air brush past on an object?

    Thank you

    (I'll probably take the House and my photoshop 5 allows you to do the job)

    In Photoshop 6 and earlier versions, the airbrush has existed as an independent tool. After that, it was moved to an option for the Brush tool.

    Airbrush simulates painting with an airbrush. When you move the pointer over an area, paint builds up as you hold down the mouse button. Brush hardness, opacity and options the Frother to how fast and how much the paint is applied. Click the button to enable or disable this option.

    If you can switch to the simulation of the voice, this video may help: How to use Airbrush in Photoshop CS6 - YouTube

  • Is there a way to use the entries in the keyboard?

    Is there a way to use the entries in the Edge keyboard? For example when you press the space bar will open a url. 'S probably done it well program.

    Control/Shift and Alt/control have their own separate event routines.

    Example of

    e.metaKey / / depends on the browser and the Apple key addresses

    e.ctrlKey / / objectives of the control or Ctrl key
    e.altKey / / objectives of the ALT key.

    e.shiftKey / / objectives of the SHIFT key

    So, if you wanted the event fires when the SHIFT key is down, then

    ///////////////

    If (e.shiftKey) {//If shift is pressed

    Window.Open ("http://www.adobe.com", "_blank");

    }

    ///////////////

    If you want to combine the SHIFT key + space bar to trigger the event and then use logical operators. In this case, you want to 'combine' key calls, then the logical operator would be a double & and demonstrated below.

    ///////////////

    If (e.shiftKey and e.which == 32) {//If key SHIFT + SPACEBAR key

    Window.Open ("http://www.adobe.com", "_blank");

    }

    //////////////

    If you want to combine the SHIFT key + a few other keyboard character Code in the above list (http://rmhh.co.uk/ascii.html), then change the value of e.which to equality (==) this character Code. Example in the list, the character Code for the keyboard "a" is 65, as amended below.

    ///////////////

    If (e.shiftKey & e.which == 65) {//If button pressed shift + a

    Window.Open ("http://www.adobe.com", "_blank");

    }

    //////////////

    To get a value from code accuarte, there are two events on this page http://api.jquery.com/event.which/, through which you can type in you field and it will capture the value for you.

    Good luck

    Darrell

  • Where are them have ways to use the iMac (end of 2015) as a monitor

    Hi all

    Where are have ways to use the iMac (end of 2015) as a monitor?
    Or maybe I can throw the bones of my macbook on iMac?

    You can not. It does not target Display Mode support.

    Use your iMac as a display with the target - Apple Support Display Mode

  • Create a target table by using the model of the ODI

    Hi all

    I am new to ODI. I'm try export table RDBMS for source RDBMS table at target.

    If we create the structure of the target in the trg schema table or we can create using the model fit obi by selecting new data store.

    Owb loading target tables is created and the data will be loaded.

    Pls help me about this.

    Thanks in advance.

    Hello
    You can create it in the two ways.if you create using ODI data store, you must select Create table option target in flow during loading of the target.

  • T-Shirt Designing (1): how to make wider white box (using the model of t-shirt)?

    CS6 using

    T-Shirt Designing (1): how to make the white box more wide inside the shirt (using the model of t-shirt)?

    Well, I learned that I can go to file > new from the template > blank template > T-shirt to start to create a design for my t-shirt.

    It shows a small picture of the t-shirt with a rectangle in the middle that also represents the large rectangle (where I create my design).

    Question, am I suppose to create the right design in the large rectangle?

    2nd... I figured out how to adjust the length and width of the largest rectangle (through the corners, then clicking on it to open the section length/width at the top of the screen). However, when I adjust the height and width, is not the same for the rectangle inside the shirt.

    What I'm trying to do, is ensure that my design takes more than forward of the sweater by expanding the width.

    How to make the small rectangle in the large t-shirt too?

    Hello

    The small rectangle in the t-shirt line drawing is a guide. So, what you need to do is unlock guides, remove the small rectangle and create a new.

    (1) go to the view > Guides > release Guides. You will now be able to edit the guides, which are light blue in my document.

    (2) just so that you know what I'm talking specifically, open the Layers panel and place you on the Guides layer. Click the arrow next to reveal the guides within the layer. I locked all the other layers in the document to make it easy for me.

    (3) select the small rectangle, and delete.

    (4) use the Rectangle tool to draw a new in size.

    5) option click on the new rectangle to open a launcher. Select make Guides.

    You now have a guide again, larger rectangle! Let me know if you have any other questions.

  • How and where can I find my Macbook Pro using the model number

    How and where can I find my Macbook Pro "using the MODEL number" NOT the serial NUMBER please...

    Hello world:

    I would like to know more about my MacbookPro using model # is if there is a website or a program that I can type my model # so she'll tell me more on my computer...?

    http://www.EveryMac.com

  • HP 1287c Windows 7: windows 7, try to use the model of hp 1287c hp 5302 keyboard does not

    have a hp 1287c windows 7 tries to use the model of hp 5302 keyboard does not respond

    try to use the old Hp keyboard model 5302 was for windows 2000 did not know if could use when I plug computor does not recognize he wonding if possible to work?

    45fmj

    Hello

    Well, the keyboard is now very cheap, the converter may not work correctly. After 16 years of him please give a rest.

    Kind regards.

  • What is a good way to check if the selection ADB sql cursor returns nothing

    Hi all

    I am trying to find a good way to identify that a select SQL basic cursor return nothing.
    I know that or we use exception when no data found or count (*) to check how many rows are returned.


    I have a cursor based on a long statement select.
    As
    CREATE OR REPLACE PROCEDURE aaa (v_input IN NUMBER, v_output OUT VARCHAR2)
         CURSOR long_cursor IS
              --long select statement(with input variable) ;
    
    BEGIN
         Select count(*) 
         Into v_count
      From
      -- a long select statment with input again ;
      IF v_count > 0 then
        For record in long_cursor loop
         --Get information from cursor
            --other processing for output
        End loop;
      END IF;
    
    END;
    Is there a way other than the above?
    I would like to reduce the amount of typing. I know that repetition in code is not good.

    Thanks in advance,
    Ann

    Published by: Ann586341 on February 28, 2013 14:29

    Hello Ann,.

    Apart from the possibility has already been mentioned that other users can change the data during execution of your process, you can check if something needs to be done without the COUNTY. Set a flag in the cursor for loop. When there is no data, then the flag will not change one you can perform the necessary procedure.

    CREATE OR REPLACE PROCEDURE aaa (v_input IN NUMBER, v_output OUT VARCHAR2)
    
        v_data_found    BOOLEAN := FALSE;
        CURSOR long_cursor IS
            --long select statement(with input variable) ;
    
    BEGIN
        For record in long_cursor loop
            v_data_found := TRUE;
            --Get information from cursor
            --other processing for output
        End loop;
        IF NOT v_data_found THEN
            -- set processed flag
        END IF;
    END;
    

    Concerning
    Marcus

  • Why thunderbird changed the way it uses the passwords of gmail accounts?

    I had put Tbird in place to always ask for a password for each account. That's always good. I could get into my gmail accounts by entering a password every time. My passwords on Tbird have not been registered. A couple of days, I had to reinstall Tbird after a computer problem. I logged into my gmail account and said not to save the password. When I logged on today it cowardly to remember passwords. I deleted them. When it tried to access accounts instead of simply ask a password he has known a rigmarole of 'connection via the gmail account' and I had confirm that Tbird is allowed to access gmail. An extra step every time, boring, but not terminal. BUT Tbird and then SAVES PASSWORDS, leaving my email accounts exposed, it's much more serious. I tried to remove the passwords, but then we went through the whole process and he did save yet. I don't want to add one master password (yet another thing to forget). I don't want Tbird automatically connect to each account every time that I load it. I DON'T want to control what he reads, and when he reads. What can I do to return to the configuration of the old?

    Since the version of Thunderbird 38 uses OAuth2 for authentication of Gmail accounts. It is the only way to be considered "safe" by Google.
    http://TechCrunch.com/2012/09/17/Google-OAuth-2-0-for-Gmail-and-talk/

    Basically, you authenticate with your Gmail account, once, and Google provides you with an authentication token. That's what Thunderbird records under "password". It is not your Gmail password. The token will expire at some point, you will need to again in the future.

    If you want to revert to the old behavior allows Google you jump through some hoops.
    You must allow 'less safe apps' in Google, or turn your settings on 2 stages of authentication in the context of a specific application password.
    https://support.Google.com/mail/answer/78754

    In Thunderbird, account settings change "authentication type" "normal password" for your Gmail account.
    You like.

  • Good way to recharge the computer to increase autonomy

    Dear support Member,

    I use a HP-Envy-Spectra-14-3010NR model that runs on Lithium-Ion battery.

    I'm not very sure about what is the best way to increase the life of my battery systems. In previous models, I have suggested to me that I must leave my battery discharge completely at least once a week and then reload.

    What is the mode of operation in suggested Lithium-Ion batteries?

    Should I still keep running on the load (with power on) or should I let it load completely, then turn off the sector until the battery is completely empty - or there is another way that is more suitable.

    Please suggest.

    Thank you.

    Hi NMahajanCA,

    It is not necessary to do the foregoing. Drain the battery or charge not completely will increase or decrease the battery life. Here is a link to understand your battery.

    http://support.HP.com/us-en/document/c00596784

    Calibrate the battery resets the battery indicator to accurately display the charge level in Windows. Here is a document on how to do it.

    http://support.HP.com/us-en/document/c00821536

    I hope this helps.

    Thank you.

  • Good way to update the linked Images Clone

    Hi guys, what is the best way to update a linked Clone image without having a ton of shots on the main template?

    To update, I know I have to do the following (not including the tasks of cleaning and others):

    1. Power on template, apply the changes (patches, app updates, etc.)
    2. Turn off - take new snapshot
    3. Tap the pool of offices on the new snapshot
    4. Recompose existing workstations using the new snapshot.

    I finally can clean snapshots or it will be just an infinite number of snapshots from 1 day up to this image gets his retirement? I made the mistake to delete the snapshot, that test workstations before redial already used to the new snapshot

    Thanks in advance.

    Exactly, I delete the older snapshots that I'm, and I feel comfortable.  I got more than 4 Active snapshots before.

Maybe you are looking for