Waiting for timeouts in parallel for loop

Hello

I am currently working on a project where I communicate with a number of devices over TCP. This happens at the same time, which is not a problem as long as does not change the number of devices. Now, I want to open my project to support the case with different numbers of hardware devices, which I want to make a loop (read the device of DB information in an array and iterate over all items).

I read on a single loop parallel execution for, but it seems that the logical cores is a limiting factor for the number of alternative treatments. Unfortunately, I must also take into account delays in communication which translates as the waiting time for each iteration of the loop.

As you can see I have this creates a lot of idle time that adds up quickly (running with 10 carrots 4 logic devices takes three times the delay to finish without the loop it would not delay time as all connections are pending at the same time.

I hope someone can direct me to a solution.

Thank you

Advertisement

Move the reference VI opened in the first LOOP.

You use the same reference for all instances.  So wait for asynchronous call will just see one of them finished and the results.  By placing the reference VI open inside your loop, you will have a different reference for each call of your VI.

Tags: NI Software

Similar Questions

  • Wait for the mechanism in the parallel execution of packages

    Dear all,

    I submit two packets in parallel as below, which works very well.

    I present this in a shell script which is registered as a front end program.

    Front end program completed in a second, while the data are not visible in the tables, the data is visible only when the execution of the package completed.

    Please can you suggest a mechanism so that I can make the plsql block in shell script to wait for both the delivery of completed packages.

    #!/bin/sh                                                                                 |
    . $CUST_TOP/bin/CUST_ID_CM.env
    export INFA_USER=$INFA_USER
    export userpass=`(echo $1 | cut -f2 -d'"' | cut -d '"' -f3)`
    ploadtype=$5 
    pyear=$7
    #####################################################################
    if [ "$ploadtype" = "Restatement" ]; then
    sqlplus -s $userpass <<EOF
    set heading off feedback off verify off serveroutput on
    spool /usr/tmp/tmp_tph_load.txt
    DECLARE
      l_cnt NUMBER;
    BEGIN
      DBMS_SCHEDULER.CREATE_JOB(job_name            => 'YEARLY_RESTATEMENTS',
                                job_type            => 'STORED_PROCEDURE',
                                job_action          => 'RESTATEMENTS_DATAFEED_PKG.INSERT_RESTATEMENTS_P',
                                number_of_arguments => 1,
                                enabled             => FALSE,
                                auto_drop           => TRUE);
      DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(job_name          => 'YEARLY_RESTATEMENTS',
                                            argument_position => 1,
                                            argument_value    => '$7');
      DBMS_SCHEDULER.ENABLE('YEARLY_RESTATEMENTS');
      DBMS_SCHEDULER.CREATE_JOB(job_name            => 'YEARLY_ACTUALS',
                                job_type            => 'STORED_PROCEDURE',
                                job_action          => 'ACTUALS_DATAFEED_PKG.INSERT_ACTUALS_P',
                                number_of_arguments => 1,
                                enabled             => FALSE,
                                auto_drop           => TRUE);
      DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(job_name          => 'YEARLY_ACTUALS',
                                            argument_position => 1,
                                            argument_value    => '$7');
      DBMS_SCHEDULER.ENABLE('YEARLY_ACTUALS');
      LOOP
        SELECT COUNT(1)
          INTO l_cnt
          FROM DBA_SCHEDULER_RUNNING_JOBS
         WHERE UPPER(job_name) IN
               (UPPER('Yearly_Actuals'), UPPER('Yearly_Restatements'));
        EXIT WHEN l_cnt < 1;
      END LOOP;
    END;
    /
    EOF
    #
    fi
    exit
    

    Your problem is the timing. You can perform the check at DBA_SCHEDULER_RUNNING_JOBS before the entry is actually in there.

    Here is an example. I just submitted a PLSQL_BLOCK waiting for 60 seconds.

    SQL> DECLARE
      2    l_cnt NUMBER;
      3  BEGIN
      4    dbms_output.put_line(systimestamp || ' - Started');
      5    DBMS_SCHEDULER.CREATE_JOB(job_name            => 'YEARLY_RESTATEMENTS',
      6                              job_type            => 'PLSQL_BLOCK',
      7                              job_action          => 'BEGIN DBMS_LOCK.SLEEP(60); END;',
      8                              enabled             => FALSE,
      9                              auto_drop           => TRUE);
     10    DBMS_SCHEDULER.ENABLE('YEARLY_RESTATEMENTS');
     11
     12    LOOP
     13      SELECT COUNT(1) into l_cnt
     14        FROM DBA_SCHEDULER_RUNNING_JOBS
     15       WHERE UPPER(job_name) IN
     16             (UPPER('Yearly_Actuals'), UPPER('Yearly_Restatements'));
     17
     18      EXIT WHEN l_cnt < 1;
     19      dbms_output.put_line(systimestamp || ' - Waiting');
     20      dbms_lock.sleep(10);
     21    END LOOP;
     22    dbms_output.put_line(systimestamp || ' - Completed');
     23  END;
     24  /
    04-DEC-14 02.32.00.075794000 AM -05:00 - Started
    04-DEC-14 02.32.00.121862000 AM -05:00 - Completed
    
    PL/SQL procedure successfully completed.
    

    Now it ends immediately. But you can see that the job is still running.

    SQL>     SELECT COUNT(1)
      2        FROM DBA_SCHEDULER_RUNNING_JOBS
      3       WHERE UPPER(job_name) IN
      4             (UPPER('Yearly_Actuals'), UPPER('Yearly_Restatements'));
    
      COUNT(1)
    ----------
             1
    

    Now I make my code to wait 5 seconds before the audit

    SQL> DECLARE
      2    l_cnt NUMBER;
      3  BEGIN
      4    dbms_output.put_line(systimestamp || ' - Started');
      5    DBMS_SCHEDULER.CREATE_JOB(job_name            => 'YEARLY_RESTATEMENTS',
      6                              job_type            => 'PLSQL_BLOCK',
      7                              job_action          => 'BEGIN DBMS_LOCK.SLEEP(60); END;',
      8                              enabled             => FALSE,
      9                              auto_drop           => TRUE);
     10    DBMS_SCHEDULER.ENABLE('YEARLY_RESTATEMENTS');
     11
     12    -- Wait for a wile before checking
     13    dbms_lock.sleep(5);
     14    LOOP
     15      SELECT COUNT(1) into l_cnt
     16        FROM DBA_SCHEDULER_RUNNING_JOBS
     17       WHERE UPPER(job_name) IN
     18             (UPPER('Yearly_Actuals'), UPPER('Yearly_Restatements'));
     19
     20      EXIT WHEN l_cnt < 1;
     21      dbms_output.put_line(systimestamp || ' - Waiting');
     22      dbms_lock.sleep(10);
     23    END LOOP;
     24    dbms_output.put_line(systimestamp || ' - Completed');
     25  END;
     26  /
    04-DEC-14 02.33.09.294256000 AM -05:00 - Started
    04-DEC-14 02.33.14.347866000 AM -05:00 - Waiting
    04-DEC-14 02.33.24.369777000 AM -05:00 - Waiting
    04-DEC-14 02.33.34.389725000 AM -05:00 - Waiting
    04-DEC-14 02.33.44.410508000 AM -05:00 - Waiting
    04-DEC-14 02.33.54.430561000 AM -05:00 - Waiting
    04-DEC-14 02.34.04.450684000 AM -05:00 - Waiting
    04-DEC-14 02.34.14.462191000 AM -05:00 - Completed
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    Now you can see the code entered in the loop and waited.

  • parallel processing: for loop taking place

    Hallo,

    I have a loop 'for' runnin on this system: LabVIEW2009, windows7, intel i7.

    I wonder if and how I can tell to LabVIEW that he would be allowed to run different iterations of the loop at the same time (concurrently) on my processor with 8 cores.

    Now, it will execute the next iteration when it ended the previous, even one so is there no dependencies in iterations.

    I want to give a 'ownership' of the loop, which means that it can be "unfolded" for parallel execution.

    Thank you

    Pier

    pop up on for loop and select "configure interation Prallelism."

    Activate it.

    Wire a certain number to the new 'P' of entry to specify how many processors to spread it everywhere.

    Ben

  • Status: Unexpected error has occurred. The timeout of waiting for an answer UVSC error internal

    Work with labview ARM and it was working fine this morning.  I went to run a program and the build failed with the following message.

    [13: 34:50] status: error
    An unexpected error has occurred.

    [Source: the timeout of waiting for an answer]

    Internal error UVSC

    Detail: [UVSC_PRJ_LOAD, MSG: 0x1000, STATUS:]
    [0x1] code: 1]

    Did normal things as restart the computer.  Plug and unplug the Board of Directors of the computer.

    I tried to reinstall the whole arm labview and it does not work.

    Even from labview so you go to tools > ARM > show keil does not work either.  I can open keil in itself, but it doesn't seem to be communicating with labview.

    Figured it out.  Somehow the projects I was working on has been corrupted somehow.  After another reinstalled, I opened a sample project, not one of the many that are mine, and it worked.  I had copy and past the code on the project and in a new, but it works.  Don't know how my projects I screwed up in the middle of work on them.

    Now, back to actually do the work.

  • stop a loop without waiting for its next iteration

    I wonder if there is a good way, or still anyway to stop a while loop without waiting for its next iteration. Lets say you have a timer in the loop so he iterates once evey 10 seconds, and then you have to wait 10 seconds for him to stop after you press a stop button that could be a problem.

    Thank you!


  • parallel for loops does not

    Hello.

    I'm learning the multi - thread programming. To start, I use "parallel for loops" and I was surprised that it does not work. One - thread loop work a few times faster (depending on settings) that multi - thread. I don't know why, and it is my request to correct my Vi to work properly.

    Lenovo, G580, Windows 7, 64-bit computer

    Intel Core i7 3632QM
    Ivy Bridge
    Specification Intel (r) Core i7-3632QM CPU @ 2.20 GHz
    Package (platform ID) Socket 988 B rPGA (0x4)
    Number of hearts 4
    Number of threads 8

    LabView 2011.

    Altenbach says:

    Gibbon wrote:

    What was 'strange' behavior?  In "linia dluga" when inside the loop is on '1' of the "spreed up' between one and multi-fil is about 3 times, when I put it in '20' this grow to 6.2. It was strange form me, becourse I expect a similar value.

    A parallel FOR loop has an overhead for parallelization (split the problem, then go back the results, etc.). If the code is very fast, the overhead is proportionally larger. If the Subvi takes a long time to complete, the overhead of parallelization is insignificant. It is often not worthwhile to parallelize the loops with a very simple and fast code.

    Gibbon wrote:

    Altenbach - I have another question if you can help me - how did you "seconds relative high resolution." VI "? -I want to say how did you know that there is this 'vi '. And thanks a lot for your modyfications.

    You can find it in vi.lib\utilities. It is well known.

    Maybe not well known enough!  the 'Hidden gems' package adds to your palattes.  It has also been considered by a nugget of the community

  • Préallouée VI environment in paralleled for loop

    Hello

    I searched a bit and couldn't find that everything about this specific issue.

    If I have a Subvi in a parallelized for loop and the Subvi is set upon reentrant preallouee clone, the Subvi register also several characteristics of memory depending on the number of loop iteration For? My specific application is a Subvi containingvibration Analytisis screw using the previous data in their spread and filters.

    Thank you!


  • LabVIEW parallel for loop and OpenMP

    Hello:

    It's just a curious post, I just learned about OpenMP and I found that OpenMP helps you to parallelize loops in c about the same way that you can use the loop For parallel in LabVIEW.

    The loop For Parallel LabVIEW is being implemented under the hood using OpenMP? Or is it just a coincidence?

    No, it is not implemented LabVIEW parallel for loop under the hood using OpenMP. You might be interested to read this article on modern developments in the LabVIEW compiler architecture. Specifically, in this case, it's the DFIR technology discussed here that facilitates parallel for loop transformations.

  • Parallel for loop 2D table

    Hello

    I don't have any experience with parallel for loops, so I need your help.

    Goal: To do a calculation (average, average) on the rows (or columns) table 2D as quickly as possible. The calculations are independent of each other and I would get a table 1 d with the results.

    I read a few posts on parallel for loops and I would like to find an example for my trivial problem, but I can't.

    Could you help me, it is possible is improve it the effectiveness of the calculation on lines with parallelism in LabVIEW? and it is, could you post an example how to do?

    Thank you

    If the speed issues, do not write your own "average." First of all, it already is in the range of statistics, but then you must be inline your average VI or do the calculation explicitly (as shown below). the size of the array never changes for the duration of the loop, it seems redundant to get the size of the array on each iteration.

    Here's what you could do.

    On my bench, it's much faster than the use of 'mean.vi' of the palette. Average a overhead, Subvi (1) (2) needs to get N with each call and (3) is also an unnecessary error checking.

    (Sorry, I have 32 processors, so the number of instances is set a little high. Modify if needed).

  • How to create parallel tasks using parallel for loops

    Hello

    I'm going to put in place a program that communicates with the six logical controllers and must read the status of the system every 100 Ms. we use OPC datasockets for this, and they appear a bit slow.

    I created a uniform method of comm. for all controllers, and now I find myself this method of programming six times to communicate with each system. I was wondering if it could be done more elegant using the parallel for loop, in which case I program an Exchange once and then six workers running simultaneously. Since a picture is clearer than a thousand words, what I'm asking is:

    Is it possible to replace something like

    by

    and that for performing these tasks in parallel loop (on different cores / in different threads)?

    I have configured the loop to create instances of the 8 to the compilation, so I would 2 surplus available when running instances if I find that I need an additional system.

    The benefits of the Show method in the second photo for me are:

    * takes less space

    * changes need be made only once

    * less blocks, son and other things makes it clearer what is happening.

    * flexibility of the actual number of tasks running (8 available runtime instances)

    * If multiple tasks are necessary, I need only update the maximum number of instances and recompile, i.e. no cutting and pasting necessary.

    Unfortunately, I don't have these available system yet, so there is no way to test this. Yet, I would like to know if the above works as I hope - unfortunately the help of labview is not quite clear to me on that.

    Best regards

    Frans

    Frans, the parallel for loop will work as expected in this situation. The six tasks will run simultaneously in different threads. What part of the aid could be made clearer?

  • When is it OK for looping while you wait event?

    Newbie question: in a world of logic non-blocking, when is it a good idea to loop waiting for something finish?

    For example, I am told to check to END_OF_MEDIA (via PlayerListener) to see if a song I played with ToneControl is finished. So is it possible to just create a loop and wait for it be triggered?

    Here is a very simple (albeit artificial) example. I want to play a melody (using ToneControl) twice. I play once, wait until it's done, then play again. END_OF_MEDIA tells me it's done. But have I not need to sit in a loop, then waiting for END_OF_MEDIA? Is it OK? It looks bad, but I don't know what would be the 'right' way.

    Thank you.

    Roricka

    The code I used was something called an anonymous inner class Java. Here's another version that does not use this construction somewhat obscure:

    void startTune() {    Player p = Manager.createPlayer(...);    p.addPlayerListener( new MyPlayerListener() );    p.start();}
    
    class MyPlayerListener implements PlayerListener {    public void playerUpdate(Player player, String event, Object eventData) {        if (event == END_OF_MEDIA) {            processEndOfMedia();        }    }}
    

    Note This class myplayerlistener is declared inside the MyScreen, right as well as the methods of the class and variable fields. All this has done is to convert an anonymous inner class in an inner class with a name.

    Now, it might look like you can move then comes from the MyPlayerListener class in a separate file named MyPlayerListener.java. But this does not work, at least not directly. The reason is related to one of the strange features of inner classes in Java (anonymous or not): an instance of an inner class carries with it an implicit reference to an instance of the containing class. That's why playerUpdate() can call processEndOfMedia() as if it was a MyPlayerListener member function, even if it is a member of MyScreen function. Somehow, an instance of MyPlayerListener lives a dual identity as an instance of MyScreen.

    If you want that myplayerlistener has stated in its own file (or if you want her to be a top-level class, not public in MyScreen.java or a static inner class of MyScreen), the rules of the language to say that there can be more than double-identity of nature. At this time, you cannot call the processEndOfMedia() in the same way as a MyPlayerListener instance does not have a reference to an instance of MyScreen. (In fact, it has no way of knowing that processEndOfMedia() is a function in the class MyScreen!) The way out of this is to give MyPlayerListener a way to refer to a particular instance of MyScreen. Here's one way:

    class MyPlayerListener implements PlayerListener {    private MyScreen client;    public MyPlayerListener(MyScreen client) {        this.client = client;    }    public void playerUpdate(Player player, String event, Object eventData) {        if (event == END_OF_MEDIA) {            client.processEndOfMedia();        }    }}
    

    Then, back in MyScreen, you need to change the call to the constructor:

        p.addPlayerListener( new MyPlayerListener(this) );
    

    And if you put MyPlayerListener in another package that MyScreen, you must also change the visibility of public processEndOfMedia().

    Anonymous inner classes are very convenient for these listener classes little, but they do not have the code a bit difficult to read. Put them in their own compilation units are more work, but it makes the code a little easier to manage, especially when come back you after a few months and try to understand what made you the way back when.

  • A timeout occurred while waiting for the host controller EHCI interrupt on answer Async ahead Bell.

    Whenever I put my adapter wireless netgear n150 under heavy load (download of World of Warcraft for example), it will go down to connection and until I restart the computer the adapter usb port is useless.  I dug into the event viewer and found that a timeout occurred while waiting for the EHCI host controller interrupt on the asynchronous response advance doorbell, source usbehci.  This seems to have been a problem with windows 8 I found other threads referencing but I can say that they are pre-release and some actually work solutions have been validated.  I already assured that all drivers, firmware and chipsets are up-to-date and compatible.  ANYONE please help?

    Quick fix I found:

    -try falling back to WiFi G rather than use N
    In my case, it works... is no longer a fall. But not the same bandwidth...
  • DatabaseError: ORA-02049: timeout: distributed transaction waiting for lock

    Hi all

    There is no script running in my data base 'A' that will select data from one table to another database via DBLINK and update tables too. The script including 6 I spin for the past 6 monts with success. Yesterday I got the error message saying that,

    DatabaseError: ORA-02049: timeout: distributed transaction waiting for lock
    ORA-02063: preceding the test line

    I have tested the link and its assets no problem in DBLINk

    I understand the objects which I access the table in locked mode.

    SQL > select OBJECT_ID, SESSION_ID, PROCESS, LOCKED_MODE from v$ locked_object where
    SESSION_ID = 121;
    OBJECT_ID SESSION_ID PROCESS LOCKED_MODE
    ---------- ---------- ------------ -----------
    77391 121 21394 3

    I have
    I killed the session 121 and in v$ session state is killed, but I get the same error repeated during execution of the script. And the session ID is always in locked_mode.

    Might add it please help with that?

    -Thank you
    Antony

    This application allows to find the OS process id for your session of people KILLED and to kill him by operating system command.

    Kill - 9 spid

    SELECT a.username, a.osuser, a.terminal, a.program, spid, SID, a.serial #.
    SESSION v$, $ v process b
    WHERE a.paddr = b.addr AND a.status = 'KILLED '.

    Concerning
    Asif Kabir

  • get the structure of the event inside the while loop to wait for event occurs before the execution

    Hello

    I have a small problem, when I raise an event using a value change button, which works very well.  The problem is that the VI does not wait for me raise an event and instead runs the same event again, even if I have not pressed the button to start again.  The mechanical action of the button switch is released is.

    I was wondering how you get the structure of the event to wait for a user event, after that he executed the first time.

    James.Morris wrote:

    There is no reason that the event should be raised twice as much that the only way that it fires in your code is by the user by clicking on 'Hall measure only'.

    Oh yes, there is, and I deserve a kudo for this one.  Mechanical action on the button is set on the switch until published, so click to generate an event, on the bottom and on the square, attached is an example.

    My boy has my students hate this question, and to be honest, I hated it.  When never would you do that intentionally?  Honestly?  Anyway to change the button back to normal (as default latch when released) and move the terminal button in the structure of the event where it is managed and it will work as usual.

  • "Wait for activity of façade" - Timeout?

    The function to wait for Front Panel activity has no output to tell if it has expired or detected activity of façade. Is there a way to output a Boolean value true if the service expires as opposed to the detection of the activity of the public Service?

    If not, is there another functions I could combine to create a work around?

    James

    Hi James,

    This should work for you.

    Mike

Maybe you are looking for

  • How can I customize the "awesome bar"?

    I just got the upgrade forced to 12 Firefox, and while I don't like for much of the new interface, I can cope. That said, I can't stand the changes to the "awesome bar". It's very distracting that it appears highlighted whenever I have my cursor on i

  • Satellite P300 - new driver for mobility radeon HD3470 graphics card

    Hello world.I want to update the driver of my screen for the most recent level available. Still the site of AMD, Toshiba answered me, I am unable to find: AMD's radeon but no mobility radeon, and 3470 series is not cited. Is anyone able to help me? T

  • fatal error C1083: cannot open include file: 'NiVisaComponent.h': no such file or directory

    I found the error of => niincludes.h (18) : fatal error C1083: cannot open include file: 'NiVisaComponent.h': no such file or directory I checked a few path, "C:\Program Files (x 86) \National Instruments\MeasurementStudioVS2005\VCNET\Include.I found

  • Wireless connection to NI9191

    He can't make connection Wi - Fi of NI 9191. Wireless on wlan0 mode is not valid. Details: [Arg_TargetInvocationException] see attachments.

  • U2515H AND S2415H

    Hello I plug just two watch a U2515H and the S2415H both are connected to a laptop HP ZBOOK 14. Laptop is connected to U2515H through displayport and the second monitor (S2415H) is connected with the first monitor with displayport U2515H HDMI output