Pass Boolean b/t parallel threads

Dear Labview Board,
I have two Labview processes that run in parallel.   One performs data input and the other data output.   They where originally designed to run independent of each other, but today I need them to perform some modest integration.   Both processes are very complex, so I would like to avoid a costly rebuild.   I'm looking for a quick and dirty solution.
I need process #1 (which is loop based) to temporarily hold execution based on a condition (Boolean indicator) in process #2.   I am not familiar with parallel processing techniques in labview, and I'm wondering if I'm making this harder than it really is.   Can I place a wait loop in one process that references an indicator in another process?   What is the easiest way to pass Boolean data between parallel threads?
Thank you,
Zach
Solved!
Go to Solution.

F. Schubert wrote:
It is written in only one place [..] global variable?
Yes.
Felix
"But can't I get away with just using a penny instead of a fuse for now?"
For the current application and assuming
1) the code will never change and
2) if it does change you will be that person and
3) you will remeber you used a global and
4) also remeber that gloabls have the potential of a race condition.
I code by the hour and do so such that my customers can confidently twaek their app without getting me involved. If I have to be involved, then I failed in my goal (sorta like what I do here on the forums )
So if the question is "can I get away with it?" then yes.
"Would I allow one of my rookies to do it?" NO
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction

Similar Messages

  • What is the fastest way to pass data between parallel threads?

    I have a top level vi running with 6 parallel threads. I need to pass some data from digital I/O to several of the threads. What is the fastest responding way to do this. I am controlling a machine that has quite a few sensed events happening at very close intervals, some as close together as 1 to 2 milliseconds, and I seem to be randomly missing the signal from these sensors. How can I distribute the I/O to the different threads and not miss any inputs?

    I usually use a Queue to pass data from one loop to another. Other
    choices are Functional Globals or Notifiers. It kind of depends on what
    you need to do as to which one is best, so it's a bit hard to recommend
    one over the others without knowing more about your application.
    Both Queues and the Functional Globals (if written correctly) can
    buffer data so you're less likely to lose data if one loop gets behind
    the others.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • Open VI Reference prevents execution of other parallel threads

    I am using splash screen to start an application. I use dynamic loading of the Main.vi and an animation during the loading, both in parallel threads (see image below). However, when the Open VI reference VI is called everything else stops executing (the animation stops running) until the Open VI reference is done. I must call the Main.vi dynamically, because it takes some time to load and I want to notify a user that the application is loading (using animation). Is there an option to prevent the Open VI reference to block the execution of other threads? Or should I use some other approach?

    andrej wrote:
    But the problem is not in the Run.VI method because the Open VI Reference blocks the execution of the top loop and I need the Open VI Reference to call the Get VI Dependencies method. Other approach could be to create a static array of dependencies and then to use this array to load VIs from bottom up.
    The only question now is if the Get VI Dependencies method returns dependencies in top to bottom order? If it does then I can just load VIs in reverse order from the array.
    Well the problem is the Open VI Reference! This executes in the UI thread, as several people have explained already (and really can't be made to do otherwise without causing a number of possible and nasty race conditions, some of them even related to the underlaying OS and not just LabVIEW itself), just as your two Property Nodes in the upper loop have to use the UI thread too.
    Once Open VI starts it only returns if it has loaded the required VI fully into memory (and that includes any dependencies that aren't already in memory) and linked them all properly together or runs into an error during loading. For this duration, NO UI Property Node can execute, which is what stalls your upper loop. If you would use local variables or terminals instead the upper loop would happily run along while Run VI loads the entire VI hierarchy but it would still not show on the UI, because in order to draw the new data from the diagram passed to locals and terminals LabVIEW has to catch the UI thread to do the UI drawing.
    So first fix is to kick out any property nodes from the upper loop and the second part of the solution is to load your VI hierarchy in chunks instead of simply loading only the top level VI directly. It would be nice if Open VI had an option to allow UI thread release between loading of chunks of VIs, but the implications are not that nice. It would be quite easy for an uncareful LabVIEW programmer to create a lockout situtation then, where two functions are in fact waiting on each other to release some locks so that the program gets hang up. And a simple warning in the documentation to watchout as this option can allow to create such lockout situations is not very useful as nobody reads them anyhow.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How can I pass an exception from one thread to another thread

    If I create a new class, that will extends the class Thread, the methode run() can not be use with the statement Throws Exeption .
    The question now: Is there any possibility to pass an exception from one thread to another thread?
    Thx.

    It really depends on what you want to do with your exception. Is there some sort of global handler that will process the exceptions in some meaningful way? Unless you have that, there's not much point in throwing an exception in a thread, unless you simply want the stack trace generated.
    Presuming that you have a global handler that can catch exceptions, nest your Exception subclass inside a RuntimeException:
    public class NestedRuntimeException extends RuntimeException
        private final m_nestedException;
        public NestedRuntimeException(final Exception originalException)
            super("An exception occurred with message: " + originalException.getMessage());
            m_nestedException;
        public Exception getNestedException()
            return m_nestedException;
    }Your global handler can catch the NestedRuntimeException or be supplied it to process by the thread group.

  • Passing a variable from one thread to another

    Hi. I'm trying to produce a chat program in Java but need to pass a variable between two threads. I have included a snipet of the code.
    import java.io.*;
    import java.net.*;
    class IndividualConnection extends Thread
         public Socket clientSocket;
         String userName = "";
         public IndividualConnection(Socket connectingSocket)
              clientSocket = connectingSocket;
    public login(String name)
    userName = name;
         public void messageUser(Socket socket, String msg)
              try
                   Socket newSocket = new Socket("192.168.0.162",5163);     
                   DataOutputStream outToServer = new DataOutputStream(socket.getOutputStream());
                   outToServer.writeBytes(msg + '\n');     
              catch(Exception e)
                   System.out.println("The connection with the client has been closed.");
                   this.stop();
    public void run()
         Socket global = clientSocket;
    // etc etc
    A number of threads are created based on code similar to the above. Each thread communicates to a different client on the chat program. However, I want to be able to send messages between the clients.
    Each thread has a method called messageUser(Socket socket, String msg). I should (hopefully) be able to send a message to anyone using the prog if I can access their socket. The problem is that the socket objects for each client is held in the clients own thread. I have tried writing some code to find the Socket object in another thread but to no success. The code I am trying is shown below.
         public Socket findContact(String name)
              ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
              int numThreads = currentGroup.activeCount();
              Thread[] listOfThreads = new Thread[numThreads];
              currentGroup.enumerate(listOfThreads);
              for (int i = 0; i < numThreads; i++)
                   String threadName = listOfThreads.getName();
                   if (threadName.compareTo(name) == 0)
                   //     Socket tempSocket = threadName[i].getClass().getField(clientSocket);
              return tempSocket;
    The line I have commented out does not work. Please could someone tell me how to carry out this task. I have spent many hours trying to solve this but am not able to. The chat server is nearly complete now. I just need to find a way of obtaining another threads socket.
    I hope the problem is comprehensible. I have found it difficult to explain clearly. Many thanks.

    Really simple, inelegant solution:
    class MyThread extends Thread {
    Socket socket;
    MyThread( Socket s ) { socket = s; }
    public Socket getSocket() { return socket; }
    }Better: create a master object that includes an array
    of sockets. Each time you create a Thread, update the
    master object's list of sockets with a reference to
    each Thread's socket. Under the current memory model, the socket field should be declared volatile. The proposed new memory model will guarantee that this will work if the socket field is declared final.
    Sylvia.

  • How to use notification with parallel thread

    Hi,
    I am learning to use Notification to communicate between thread. I still don't know how to use it. In my current project I have a case to use this so I think I should implement this technique. My example is I have a main sequence in that I make a new thread. What I want is the new thread will do a task A when receive a notfication or to exit the thread when the main sequence stop.
    I am not sure if using notification is a best practice here? Or should I use a reference data?
    What about if I want my thread to do task B if it receive another notification. Is notification still be helpful?
    Regards,
    Thang Nguyen
    Solved!
    Go to Solution.

    Hello,
    You can use Notification to handle parallel threads. I often create two sequences : one containing the process A of your example (StartProcessA). and a second one to stop this process (StopProcessA). In StartProcessA, I create a Notification, with a defined name (as string constante, "StopProcessANotifier" for instance) in the setup group. Then I have the process, in a loop. At the end of this loop, I check the Notification (Wait) with a  timeout enabled, and no error if a timeout occurs. this way, the Notification Wait can be used as loop timing, and if the notification is Set in MainSequence, this exit the loop (pick a look at Notification property Step.Result.TimeoutOccured).
    To sum up, use a first sequence call in MainSequence, calling StartProcessA, with NewThread option, and do not forget to call StopProcessA at the end of you MainSequence. The Cleanup group is a very good location, because it will be executed even in case of error.
    This is a very simple use of Notification. Note, I believe that make it simple is often the most important but also the most complicated thing to do 
    Hope this helps....
    .mrLeft{float:left} .mrInfo{border-left:solid 1px #989898;font-size:x-small;color:#989898}
    Mathieu R.  
      CTD - Certified TestStand Developer / Développeur TestStand Certifié  
      CLAD - Certified LabVIEW Associate Developer  

  • Parallel threads does not work with brtools 7.20(12)

    hi,
    I am trying to rebuild an index online with BRTOOLS 7.20(12) and trying to specify parallel threads more than 1 which does not seem to accept, is this a know issue  .
    BR0657I Input menu 356 - please enter/check input values
    Options for rebuild of indexes: SAPSR3.VBOX~A (degree 1)
    1 * Rebuild action (action) ................... [rebuild]
    2 - Rebuild mode (mode) ....................... [online]
    3 ~ New destination tablespace (newts) ........ []
    4 - Parallel threads (parallel) ............... [1]
    5 ~ Index parallel degree (degree) ............ []
    6 ~ Category of initial extent size (initial) . []
    7 - Compression action (compress) ............. [none]
    8 # Index compression method (indcompr) ....... [ora_proc]
    Standard keys: c - cont, b - back, s - stop, r - refr, h - help
    BR0662I Enter your choice:
    BR0280I BRSPACE time stamp: 2011-08-16 17.27.17
    BR0663I Your choice: '4'
    BR0682I Enter integer value for "parallel" (1-1) [1]:
    BR0280I BRSPACE time stamp: 2011-08-16 17.27.20
    BR0684W Invalid value for "parallel": '4'
    BR0682I Enter integer value for "parallel" (1-1) [1]:
    BR0280I BRSPACE time stamp: 2011-08-16 17.27.41
    BR0684W Invalid value for "parallel": '4'
    BR0682I Enter integer value for "parallel" (1-1) [1]:
    BR0280I BRSPACE time stamp: 2011-08-16 17.27.43
    BR0684W Invalid value for "parallel": '2'
    BR0682I Enter integer value for "parallel" (1-1) [1]:
    BR0280I BRSPACE time stamp: 2011-08-16 17.27.47
    BR0684W Invalid value for "parallel": '3'
    BR0682I Enter integer value for "parallel" (1-1) [1]:
    BR0280I BRSPACE time stamp: 2011-08-16 17.27.49
    BR0683I New value for "parallel": '1'
    thx Jonu

    Hi,
    you can check in option itself, range is 1-1
    BR0682I Enter integer value for "parallel" (1-1).
    try with Index parallel degree.
    thanks
    ashish

  • Passing boolean values to DLL

    Hi,
    Currently I am using VB .NET to pass a boolean to a DLL... i've tried this with Strings and did not have a problem... but when i want to pass booleans over, i got a 'System.EntryPointNotFoundException' error  ...
    i suspect the problem lies with LabVIEW not accepting boolean as 'True' or 'False', or '1' or '0'... or am i wrong?? any help is greatly appreciated  ...
    attached is a simple code... hope i did it correctly...
    Best Regards,
    JQ
    LV 8.0 user...
    Attachments:
    display.zip ‏66 KB

    JQ wrote:
    thanks tst and dave... i think this may be the problem  ...
    In LabVIEW, a Boolean is one byte. In Microsoft Visual Basic, a Boolean is two bytes. In Microsoft Visual Basic, if you declare variables as Booleans, the memory becomes corrupted or overwritten. Instead, you must declare each variable as one byte. The Booleans are passed by ref because they are set up as pointers to values.
    quoted from: http://zone.ni.com/devzone/cda/tut/p/id/3188#toc1
    although this is VB... but i think VB and VB .NET should be using the same data type.. if i succeed i'll inform you guys again... thanks a lot for the help...
    And in Win32 API a BOOL is 32 bit. It's amazing how even Microsoft can not decide what is best.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Quick question on passing booleans

    I have a method that accepts a boolean and am then wanting to set boolean or it's negative throughout settings
    is there a quick means of getting the opposite from the passed boolean??
    as in:
        private void CoreCourseSelected(boolean b) {
            elect12.setSelected(b);
            elect12.setEnabled([negative b]);
            elect6.setEnabled([negative b]);
        }apologies ...I'm sure it's obvious

    Yup:
    elect12.setEnabled(!b);
    elect6.setEnabled(!b);

  • How many parallel threads

    Can any of you point to a query to show how many parallel threads are being used by a specific OSUSER. A load runner test is being done and the application server issues a set of dmls to an Oracle database. The v$session table shows all the sessions associated with the (application server) osuser have status 'INACTIVE'. Does it mean that none of the dmls are being executing? Which other data dictionary tables/views do I need to join to v$session to get a correct picture of the parallel threads being used.
    Thanks in advance.

    Yuri_IL
    You need to download the 488.2 driver. Make sure that you include the support for .NET framework. You specify this during the installation.  
    NI-488.2 3.1.1
    http://www.ni.com/download/ni-488.2-3.1.1/3786/en/
    In the following readme file you can find .NET framework compatibility, GPIB interface compatibility and other details that might be of your interest. You can also find where the .NET examples are going to be located.
    NI-488.2 for Windows, Version 3.1.1 Readme
    http://ftp.ni.com/support/softlib/gpib/Windows/3.1​.1/ReadMe.html
    The following manual explains all of the functions that are included in the driver API
    www.ni.com/pdf/manuals/370428f.pdf
    http://www.ni.com/pdf/manuals/370428f.pdf
    Warm Regards,
    William Fernandez
    Applications Engineering
    National Instruments

  • Creating parallel thread

    Hi guys,
    I want to create a parallel thread with one .VI in it. How can I create one and how to set priority and time interval. This .VI checks if a device is alwayz present. I want this thread to start after a certain step.
    Solved!
    Go to Solution.

    Hi,
    You can use a Sequence Call (put the VI inside that)  and configure the Sequence call  to run in a separate thread (Module - Execution Option - Use New Thread)
    AshwiN,

  • Pass boolean parameter?

    I need to pass a boolean (true/false) for load complete, so i can shrink down tons of codes.
    But its not working.
    How should the code look like?
    function myLoad() {
         //load codes
         var pass:Boolean = new Boolean(true);
         myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE , function(e:Event) { loadComplete(e, pass) } );
    function loadComplete(e:Event, pass:Boolean):void {
         if (pass = true) {
             trace("do something");
         } else if (pass = false) {
             trace("do something else");

    I don't know about passing arguments via listeners, but as far as conditionals go, "=" is not what you want to use... "==" is for comparison.  And if you are testing boolean values you don't need to write out the comparison....
    if(pass){
    } else {
    And as I said, I don't know about passing arguments via listener function designations, so if you've had success doing that before, then fine.  I have been led to believe it is more complicated a matter to resolve.  Without knowing how to do it otherwise, while it might involve more lines of code, I would use the conditional test to assign the listener rather than to decide which code to use in the loadComplete function.  So I'd use one of two listeners and one of two complete functions thru them..

  • Passing booleans to LabView dll

    I have created a Labview vi (7.1) that I have converted to a dll which uses a cluster of Booleans as a input. I set Test Stand (2.0) to pass a Structure (1 byte boundary) with Booleans as the data type (Test Stand also asks for a numeric type for some reason); is this the correct method?  I get the message 'no type information in the dll' when loading the dll from Test Stand, is this normal for Structure/Cluster passing?

    Hi Steve,
       the No type information relates to the parameters being passed, so you have to make it up yourself in TestStand to match the setup you've given in LabVIEW when you built the .dll
    LabVIEW packages booleans as U8's, so that's why it's asking for a number - there is no BOOL type itself - we address by byte only.
    http://digital.ni.com/public.nsf/websearch/DBCE27265FFB554986256C9400026FE8?OpenDocument
    This means that booleans are essentially a complex type, however useing U8s instead uses the same amount of space, and if you're not using clusters to simply keep them together, then you'll get prototype information out.
    Useful other threads below :
    http://forums.ni.com/ni/board/message?board.id=170&message.id=122260&requireLogin=False
    http://forums.ni.com/ni/board/message?board.id=330&message.id=6140&requireLogin=False
    Hope that helps
    Sacha Emery
    National Instruments (UK)
    // it takes almost no time to rate an answer

  • How to pass the caught exception in Thread.run back to the main program?

    I have following three Java files (simplified from a real world application I am developing, see files at the end of this posting):
    1. ThreadTest.java: The main program that invokes the Manager.run()
    2. Manager.java: The manager that creates a thread to execute the Agent.run() for each agent
    3. Agnet.java: The run() method can throw Exception
    My goal is twofold:
    1. To execute the run() method of an Agent in a thread (the reason for this is there are many Agents all managed by a Manager)
    2. To catch the exception thrown by Agent.run() in the main program, ThreadTest.main() -- so the main program can alert the exceptions
    My problem:
    Bottomline: I cannot pass the exception thrown by Agent.run() in the Thread.run() back to the main program.
    Explanation:
    The signature of Thread.run() (or Runnable.run()) is
    public void run();
    Since it does not have a throws clause, so I have to try/catch the Agent.run(), and rethrow a RuntimeException or Error. However, this RuntimeException or Error will not be caught by the main program.
    One work-around:
    Subclass the ThreadGroup, override the ThreaGroup.uncaughtException() methods, and spawn the threads of this group. However, I have to duplicate the logging and exception alerts in the uncaughtException() in addition to those already in the main program. This makes the design a bit ugly.
    Any suggestions? Am I doing this right?
    Thanks,
    Xiao-Li "Lee" Yang
    Three Java Files:
    // Agent.java
    public class Agent {
    public void run() throws Exception {
    throw new Exception("Test Exception"); // Agent can throw execptions
    // Manager.java
    public class Manager {
    public void run() throws Exception {
    try {         // <===  This try/catch is virtually useless: it does not catch the RuntimeException
    int numberOfAgents = 1;
    for (int i = 0; i < numberOfAgents; i++) {
    Thread t = new
    Thread("" + i) {
    public void run() {
    try {
    new Agent().run();
    } catch (Exception e) {
    throw new RuntimeException(e); // <=== has to be RuntimeException or Error
    t.start();
    } catch (Exception e) {
    throw new Exception(e); // <== never got here
    // ThreadTest.java
    public class ThreadTest {
    public static void main(String[] args) {   
    try {
    Manager manager = new Manager();
    manager.run();
    } catch (Throwable t) {
    System.out.println("Caught!"); // <== never got here
    t.printStackTrace();

    The problem is, where could you catch it anyway?
    try {
    thread.start();
    catch(SomeException e) {
    A thread runs in a separate, er, thread, that the catch(SomeException) isn't running within. Get it?
    Actually the Thread class (or maybe ThreadGroup or whatever) is the one responsible for invoking the thread's run() method, within a new thread. It is the one that would have to catch and deal with the exception - but how would it? You can't tell it what to do with it, it (Thread/ThreadGroup) is not your code.

  • Passing boolean parameters to Oracle

    Hello there everyone.
    I have just started to work with Oracle stored procedures. I
    have written a procedure that takes a boolean value as one of its
    input parameters, but I cannot find out how to get Coldfusion to
    pass the value in correctly. If I execute the procedure within the
    Oracle client itself it works OK but CF always gives the error
    "PLS-00306: wrong number or types of arguments in call to
    'PROC_TEST' ORA-06550: line 1, column 7: PL/SQL: Statement
    ignored", no matter how I try to pass my boolean value. I have
    tried to use all combinations of CF_SQL_BIT and CF_SQL_INTEGER and
    "1" and "true" and "TRUE" in the <cfprocparam> tag, but none
    of them are working. I guess I could change the code to use an
    integer instead, but using a boolean for this example makes the
    most sense.
    If anyone has any ideas, that would be great.
    Regards
    Barry.

    Hi Phil thanks for replying!
    I continued searching Google and came up with the same
    conclusion you mention. Here are a couple of links:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#34_05
    http://www.utexas.edu/its/unix/reference/oracledocs/v92/B10501_01/java.920/a96654/tips.htm #1005343
    What a strange situation to be in. On one hand they say that
    "booleans" can't be used outside of PL/SQL, but what ARE stored
    procedures if not PL/SQL? Musing about this does not move us
    forward though I think.
    I will change my boolean parameter to be something more SQL
    (without the PL!) friendly.
    Thanks for getting back to me.
    Barry

Maybe you are looking for

  • How to connect crystal report 10  to Borland JDataStore?

    Post Author: badong CA Forum: Data Connectivity and SQL i am new to crystal reports for Borland JBuilder. Does anyone knows how to connect it to the database created in Borland JDataStore? i would appreciate if you could provide the configurations.

  • Non functional shortcut in keynote 3  -  problem to loop with QT slides

    Hello there, I'm using the shortcuts of Keynote a lot, and I'm embarrassed by the following strange behaviours : 1) in a slide that contains built-ins effects, none of the forseen shortcuts (P, Delete, Page Up, Left Arrow, Up Arrow, or Shift-Up Arrow

  • Changing the namespace prefix in OSB body content

    I would like to change the namespace prefix of the namespace in the content of the Body in OSB (Replacing g: with dg:) For example: <g:Information> <g:firtName>John<g:firstName> <nc:date>1970-01-01<nc:date> </g:Information> should become <dg:Informat

  • Date Created files are listed as 12/31/1903 ???

    All my files and folders listed under: Date Created has incorrect dates of Descember 31, 1903. Files under Date Modified are correct. System files and apps are also not affected. These incorrect dates are on my internal drive and also on my PC backup

  • Photoshop 12.1 32 bit and Windows 7 autoplay issue

    Hello.  I've come across a problem with Windows 7 and photoshop and I was wondering if someone can point me in the right direction. I installed Adobe Masters Collection 5.5 on a PC that has Windows 7 32-bit.  It has Photoshop 12.1 installed.  When I