Multi-Threading in Labview (not teststand)

I have heard that it is possible to write a Labview application using
more than one execution thread, but I don't understand what the help
files are saying.
Do I have to have a HyperThreading CPU to do this?
This was easy in CVI.
Can more than one thread make changes to the front panel controls or even display it's own panel?
Maybe someone has some pointers or simple examples of how to create a second thread.
(Please - no TestStand examples. Just 100% Labview)

You don't need hyperthreading. Parallelism is built into LV in several levels. First of all, you can simply have parallel code by having 2 pieces of unconnected code which will run "in parallel" (the scheduler will make sure they both get executed).
You can assign priorities and threads to VIs by going to File>>VI Properties>>Execution, but there is usually no need to deal with this because is LV will be fast enough without this (plus, you have to know what you're doing).
Like I said earlier, if you just want different pieces of code to execute in parallel, just make sure they are not connected. You can open as many VIs as you like like this and let them execute in parallel. You can have seperate loops updating controls on the same front panel. Basically, whatever you like. It's really very simple. If you want an example, simply create 2 while loops which do something, and you can see they do it the same time.
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
Try to take over the world!

Similar Messages

  • How can i use multi threading in labview?

    i want to run a Digital storage oscilloscope and an energ ratio meter simultaneously using labview. i am using GPIB interfacing and windows XP. how can i do this using multi threading. Bot the instruments shd run and give data at the same time.

    You can't do this - at least not with a single GPIB board. It has nothing to do with threading or LabVIEW. There can only be one talker at a time over the bus. Depending on the instruments, you could probably set them up to take measurements simultaneously but you have to sequentially poll them to get the data.

  • Would you give me some information about objective-c multi thread

    hello,
    I am studing objective-c multi thread, but have not enough information. would you give me some, please? Thanks very much!

    Have you tried the ADC pages: http://developer.apple.com/macosx/?
    Multi-threading can be a complicated business in any programming language, so good luck!

  • Would you give me some information about objective-c multi thread please

    hello,
    I am studing objective-c multi thread, but have not enough information. would you give me some, please? Thanks very much!

    Hello
    You rang at the wrong door.
    This forum is dedicated to AppleWorks, not to objective-c
    Yvan KOENIG (from FRANCE mercredi 9 août 2006 07:38:25)

  • Teststand calls all threads fine, Labview OI does not..

    Hello all,
    Thanks to the many help provided on this forum, I was able to create a Labview OI and a Teststand seq. file for my application. However, there is something weird happening that has baffled us all.
    The TS seq. file has 5 parallel threads running in a sequential process model for approximately 1 minute. After a minute, all of them stop simulatenously. Now among the 5 threads is a DAQmx-Simulink simulation modeling that simulates the motor dynamics of an automobile. This particular thread executes fine in the TS environment, and cleanly shuts down after execution.
    Now, when I load the entire sequence file onto my LV 7.1 OI, the DAQmx-Simulink model fails to execute and gets stuck at AO Read, thereby stalling the completion of the entire process. This same seq. file again works just fine in the TS environment. It used to work earlier during the day, and after some modifications in the TS .seq files, we tried it again..and it would not work at all. I didn't make any changes in the OI code.
    Can someone please suggest, why this could happen? I've reached a dead end and can't think of any reason
    Many thanks in advance,
    Anshul

    Hello Anshul,
    I would recommend trying to narrow down the problem to a more simple situation. If possible, I would see if you can run your sequence through the OI that ships with TestStand. If that works correctly, then the issue is likely being caused by programming in the custom OI. If that still does not work, I would modify the client application to only have the one thread that is not behaving correctly. Incrementally try to make the code as simple as possible, removing as much extra programming as you can.
    Thank you for contacting National Instruments. Please write back when you have more information about the problem. If you are able to narrow it down enough so that it can be replicated on another machine, that would be optimal (but may be impossible if the error is linked to hardware or 3rd party software that our Applications department does not have access to). Take care and good luck!
    Regards,
    Aaron B.
    National Instruments

  • Teststand New Thread VS LabVIEW "Call & Forget" Asynchronous call

    Hi everyone,
    Here is an example taken from the ni.com website showing how to use LabVIEW to post a TestStand Notifier.  I have modified the example to fit the situation I needed to use it for.  I have an example which works fine (When I use a TestStand new thread to launch the Notifier VI) and an example which does not work (When I use a LabVIEW "Call & Forget" Asynchronous call to launch the Notifier VI).
    I would like to understand why it doesn't work in the second situation. The reason why I would prefer the 2nd situation which currently doesn't work is that I try to eliminate all multi-threads from an obsolete sequence written by someone else a few years ago so that I can troublesoot it and update the code to make it work with today's new reality.
    Also, for my personal knowledge.  I don't understand why the second strategy doesn't work.  The Testsand notifier reference is the same and hadled the same way.  I have included my example files with the 2 situations in seperate sequences files.
    Thanks in advance to the person who will be able to enlight me.
    Nien 
    Solved!
    Go to Solution.
    Attachments:
    New Thread Or Dynamic Call.zip ‏41 KB

    Hello Nien,
    This isn't a TestStand issue.  I suggest you take this to the LabVIEW forum.  Looking over your code your Notifer and Forget.vi is dependent on the notifier.vi.  So it's not necessarily anything wrong with the sequence steps but actually within your LabVIEW code itself.  One suggestion is to insert a simple error handler.vi in your Call Notifier and Forget.vi.  You have error wires connected to the functions itself, which is good practice but you don't have anything to inform you if an error occurs or not.  I would suggest you to run try to debug your LabVIEW code, such as using highlight execution, while you're running your code so you know where exactly the error is happening.  
    Thanks,
    Jonathan R.
    Applications Engineer
    National Instruments

  • VI calling from a multi-thread Teststand

    Hello,
    My test system tests four UUTs at the same time(with batch mode in TS), the code is based on LabVIEW and call from TS, so every step the same VI will be accessed by four thread. however, it runs quite slow even i set the reentrant execution in VI propertise.
    My Quesition:
    Can I do it like this in multi-thread mode of TS?
    How can I make it fast? (convert VI to dll?????)
    Any help will be appreciated.
    Thanks,Steven

    Hello Allen,
    Thanks for your help.
    Problem: I have a LabVIEW VI with parallel code blocks. These blocks run in parallel as expected when I run my VI directly or from a top level VI. However, the code blocks seem to run sequentially when I call my VI from TestStand. Why is this happening and how can I fix it?
    Solution: In order to fix this behavior, simply set the VI Properties of "Execution" of your LabVIEW VI to "Other 1" or "Other 2". This change will make the parallel code blocks in your LabVIEW VI run in parallel as expected. To change this setting, from your LabVIEW VI, go to File»VI Properties. Select the Execution category. Change the Preferred Execution System to be either other 1 or other 2.
    You need to make this change to any LabVIEW VI with parallel code blocks that is called from TestStand. The reason for this is that TestStand is using the LabVIEW ActiveX interface to run LabVIEW VIs. The LabVIEW ActiveX interface sets the caller's execution system to "User Interface" by default. This execution system is not recommended for a VI with parallel code blocks. If your LabVIEW VI's execution system is set to "Same as caller" (which is the default setting when creating a new LabVIEW VI), then it is executed in the User Interface thread when run through the LabVIEW ActiveX interface. This prevents the blocks to be executed in parallel.
    In fact, only one block in my LabVIEW code, but it accessed by four thread from TS. I am sure that my VI can be accessed by four thread simultaneously if I enable the reentrant excution in VI property. I also have tried what mentioned in above document but no use.
    However, if i only add a 1000ms delay to my LabView code instead of the 'calculation', it is fast enough!  what is happening or something i set wrong?
    I don't want to convert all my LabView code to DLL cos too many VIs here, and difficult for mantenance either.
    Any other good solution???
    Thank you Allen...
    Steven

  • LabVIEW built DLL's in a multi-threaded C++ app, Help Needed!

    I'm working on a software application that is being developed
    primarily in C++. There is a component of this larger application,
    however, that is being developed in LabVIEW (for several reasons that
    I won't dive into here). This LabVIEW code is therefore executed
    within a C++ wrapper class that calls a LabVIEW built DLL.
    All this was fine and dandy, untill we decided to multi-thread our C++
    application. As a result, the LabVIEW DLL now gets called from
    multiple threads simultaneously. From all of my testing, it appears
    that resource locking is occuring such that only one thread has access
    to the .dll at a time. If I make the .vi used to define the dll
    function prototype as non-reentrant then this is what we see. As an
    example, say we have 3 threads all calling the same .dll method call.
    Thread 1, 2, and 3 all call the .dll within a few milliseconds of each
    other. Thread 1 completes the .dll call after X milliseconds. Thread 2
    completes the .dll call after 2X milliseconds, and thread 3 completes
    after 3x milliseconds.
    Now, changing the vi to reentrant, and running the same test, we see
    Thread 1, 2, and 3 all complete the .dll call in 3x milliseconds.
    While the fact that they now take the same amount of time to complete
    would lead you to believe they are happening in parallel, the fact
    that it takes 3x milliseconds as opposed to X milliseconds means they
    are not.
    Has anyone ever dealt with these issues before? Is it possible that
    messing with the "execution system" for the vi will have an affect?
    What if different .dll methods but still attached to the same .dll are
    called from different threads? Same behavior? Is it a lost cause? Is
    there no way to make code within a single LabVIEW built .dll run in
    two different threads at the same? From what I understand this is
    easily doable with a normal (non-LV built) .dll.
    Please, if anyone has any advice in this area, let me know!!!
    Much appreciated,
    Jesse Hurdus

    Duplicate post.

  • Multi-threaded agent not being used

    Solaris 9, Oracle 9.2.0.1
    The docs say the multi-threaded agent avoids processes starting every time a user opens a database connection. Except it doesn't seem to.
    I've started up the agent;
    ps -ef |grep hsodbc
    oracle 6193 1 0 14:21:07 ? 0:00 hsodbcMYSQL_R -mt
    But, when I establish 2 user connections across a database link, I see this;
    ps -ef |grep hsodbc
    oracle 6201 1 0 14:21:40 ? 0:00 hsodbcMYSQL_R (LOCAL=NO)
    oracle 6216 1 1 14:23:08 ? 0:00 hsodbcMYSQL_L (LOCAL=NO)
    oracle 6193 1 0 14:21:07 ? 0:00 hsodbcMYSQL_R -mt
    The multi-threaded agent isn't picking up and processing the connections as I would expect. Processes are being spawned in exactly the same way as when the mt agent is not running.
    I have checked the listener logs and the agent is registering ok at startup [and every 10 secs too!!!].
    Can anyone shed any light on why I am not seeing the benefits of the mt agent?
    TIA
    Steve

    Steve,
    MTA is not supported with Generic Connectivity.

  • Asynch Event Gateway not multi-threaded?

    Hi there,
    I've stumbled upon a huge problem and I would greatly
    appreciate your help otherwise I am looking at a major rework of my
    application :S
    I thought that any event gateway (asynch) would be
    multi-threaded? that is, multiple users can call the event gateway
    at the same time and this would just fire up threads of the event
    gateway and parallel processing of the cfc will occur?
    However, that is not whats happening in my application. My
    event gateway is called from a webpage and it computes (very
    complicated and time consuming data) its data and creates a file
    with a unique filename. However, if more then 1 user submits a job
    at the same time, it only takes the first job, finishes it and then
    starts working on the next job in the queue. So if there were 5
    users who submitted their jobs one after the other, the event
    gateway will take their jobs one by one which is very bad for me.
    Is there a way to have event gateway work on multiple jobs at
    the sametime??? or is this just not possible?
    I will greatly appreciate your reply. thank you
    using Coldfusion MX 7, WINXP

    My event gateway is called from a webpage and it computes (very
    complicated and time consuming data) its data and creates a file
    with a unique filename. However, if more then 1 user submits a job
    at the same time, it only takes the first job, finishes it and then
    starts working on the next job in the queue. So if there were 5
    users who submitted their jobs one after the other, the event
    gateway will take their jobs one by one
    I'm not so sure about your conclusion in the case of 5 jobs.
    The 5 jobs may start in the order in which they were triggered, but
    might end in a different order. Also, there could be some
    multithreaded processing between the first job starting and the
    last job finishing. Threads can be unpredictable worms.

  • CS6 After Effects PNG export very slow - Not Multi-Threaded?

    I am rendering an after effects project consisting of over 320,000 source frames of 4000x4000 resolution, outputting over 250,000 frames as PNG files.
    Rendering is instant on our machines, all time is spent "compressing and writing" frames. It is taking forever.
    We have several machines that are all windows 7, with 16 physical cores, 64GB ram, connected to a 4Gbit SAN.
    I did some experimenting, tried using all 16 cores, or 8 cores, or disabled multi-frame rendering even. When this project is rendering my cpu usage is almost non existent,. maybe 1%-5%  at times.
    with 16 frames at a time being rendered it is averaging between 1 and 7 seconds per frame depending on the content of the frame.
    Does Adobe have any plans to multi-thread the PNG exporter? or is there a faster 3rd party plugin out there i could use? It is very slow and doesn't tax the CPU's at all. Even on a single core it doesnt even use 100% cpu while its saving.
    I even tried loading one of the frames into photoshop and simpy hit save as a PNG and it took almost 15 seconds to compress and save. I did it again without compression and it saved the 40MB raw file instantly.
    That is terrible performance for machines like mine that are pretty much the fastest things out there.
    Thanks!

    I appreciate your attempt for a workaround solution, however as you well know you can't render to a video file from multiple machines. we must output directly to individual frames, I setup 8 machines to work on this project, if we did not use compression then we would be writing over 300MB/sec of data which would not be good for our fibre network which unfortunatly is only 4Gbit. And it would be about 10TB of data total.
    As for your workaround Im not sure we could gain speed with your method either way. spending the extra time to encode to a lossless format and then process again in AME sounds like it would take even more time, unless AME could create PNG files at some sort of ridiculous speed maxxing out every core at 100% or something to compress the PNG's. Out of curiosity I will throw some frames at AME and see how long it takes to compress and how much cpu it will use.
    thanks

  • Highlight text not working in multi-thread client-server application plug-in

    I'm developing a plugin application for my dissertation research on multi-application environment. I have an application server that communicate with the PDF document via plugin.
    The plugin acts as both client and server, depending on the situation.
    - Plugin as Server
             I have a multi-threaded winsock2 IOCP running to catch client connections and when a client connected, get the data from the client (set of words), and highlight these words in the pdf document.
    - Plugin as client
               I use 2 procedures, one to collect all the text from PDF and send to the server using tcp win-socket connection and another to collect data from highlight tool and send these text. both these are not threaded.
    Here's my question, because I want to listen to multiple client connections, when the plugin is the server, I'm running this procedure in a thread and then wait for clients to connect and use IOCP to serve the client connections.  When the client is connected I use the data coming from client to highlight some text in the PDF document. All of these functionalities are already implemented, but when I receive data from client and try to highlight text in the PDF document my application freezes up and stop working. I think this is something to do with the thread. I'm using _beginthreadex to start the server and then another _beginthreadex inside the IOCP worker thread.
    I can post the code, but before that let me know if you can see any problem in this situation. What I see from other posts is that acrobat is not multi-threaded.

    Thanks a lot for the reply.
    I guess I probably need some sort of a notification when the data is received and do a callback to the main thread to run the acrobat API. Is there anyway I can create custom notifications? Something like this,
    AVAppRegisterNotification(AVDocDidOpenNSEL, gExtensionID, ASCallbackCreateNotification( AVDocDidOpen, (void *)DocIsOpenedCallback), NULL);
    or should I use a custom action listener?

  • Multi-threaded undercutting of dual locks in TestSTand 3.0

    Group,
        I have a test sequence that is running 16 threads to test radios.  About midway into my testing one of the threads will some how take priority and will not wait for another thread to finish its testing.  The first time a thread executes a series of tests all is fine.  But when the second or later thread attempts to run the same code it is always stops waiting for the thread that is one dual lock ahead of it.  Let me setup the condition.  Assume Thread 1 is just finished with Lock Audio and Thread 2 begins executing Lock Audio.  At some point in the middle of the dual locks sequence, Thread 1 takes priority and begins running its test leaving Thread 2 having not finished its set of tests within the dual locks.  In fact, thread 2 is unable to do anything until thread one has gone completely through its entire sequence file.  How can one thread countermand the previous thread.  Example of testing below:
    Lock Audio
    Lock PortAA
       Take a measurement
    UnLock PortAA
    Lock PortAA
       Take a measurement
    UnLock PortAA
    UnLock Audio
    Lock VolumeMax
    Lock PortAA
       Take a measurement
    UnLock PortAA
    Lock PortAA
        Take a measurement
    Unlock PortAA
    UnLock VolumeMax
    ..........etc..............

    Did you mean to have an unlock audio in the middle? It seems odd that Port AA is sometimes used under the audio lock and sometimes not. It makes me think you might not really be locking/unlocking the locks that you intended to.

  • Using multi threading to access 2 RS232 ports

    Hi,
    I'm a beginner in multi threading, so this question may be a very basic one....
    I'm Using TS3.5 + CVI 8.01 to communicate withs 2 RS232 ports.  I thought to use mult threading so I can process 2 steps in parallel rather than in series. 
    This is what I do:
    1) I defined 2 subsequences, each of them call the same CVI function.  I use the sub sequence parameters to transfer the com number.
    2) My CVI application includes one dll for this specific project and another one, a general dll to handle RS232 functions.  The RS232 dll uses one global buffer than collects all the traffic on the com. 
    QUESTIONS:
    1) What happens when 2 seperate threads run the same function in the RS232 dll?  (in terms of memory etc...).  Does each one use a different buffer (in terms of memory allocation), or, both of them writes to the same buffer?   Obviously, if they writes to the same buffer, then, my function will not operate properly.
    2) What happens in TestStand after the 2 steps in new threads have finished their execution?  does the next step run back in the same threads the sequence run before?
    Thanks
    Rafi

    Rafi,
    Glad to hear you were able to make some ground on your application. As for all of your questions, I'll try to answer as many as I can.
    First, when you are talking about your global buffer, is it created in TestStand or in the DLL itself? When you use DLLs, global variables or global structures are shared between all threads that call your DLL. On the other hand, if your buffer is declared inside of the DLL it is global for the DLL but not shared and would be a separate buffer for each call.
    With your run-time error in TS, it would definitely be helpful to have more information about the error. From what you explained (executing fine on the first call, but failing on future executions), it sounds like the resource is not being released after the first execution.
    As far as a specific example for TestStand Multithreading, you'll want to look at the TestStand Development Library and, specifically, Multithreading in TestStand. If you look and browse through the Application Notes and Tutorials section, as well as the Technical Presentations section, you will learn a great deal about multithreading and what options you have in TestStand. For a specific example, you may want to look at This Example. You could also look in the <TestStand>\Examples (where <TestStand> is the directory where TS is installed) at the MultiUUT example for an example of multithreading in TS. These examples may not be exactly what you need, but they should give you a jump start.
    As far as making your DLL multithread safe, it is definitely not necessary; however, there are some significant advantages described in this article: Designing Thread-Safe DLLs. It is an MSDN article that focuses on Visual Basic, but it has some helpful information that can apply to C as well.
    Hopefully this can help you move further. I have attached a list of links at the end of this post with other helpful links for you as well. Keep us posted with your progress.
    Matt Mueller
    NI
    Links:
    General Information on Multithreading for C Programmers
    Building Multithreading Applications with LabWindows/CVI
    Multithreading in LabWindows/CVI
    Easy Multithreading Programming in LabWindows/CVI
    Multithreading for Rookies

  • Multi threaded operation

    can i call system thread in labview as we do in mfc programming.

    I don't think you can, but depending on your application you probably don't need to. LabVIEW is inherently multi-threaded, so it will automatically run parallel processes in separate threads if it is possible to do so.
    Here is a link to an app. note which should help shed some light on the subject:
    Using LabVIEW to Create Multithreaded Applications for Maximum Performance and Reliability
    Hope this helps you!

Maybe you are looking for

  • How to install Oracle 11gR2 on Windows 7

    Hi friend; There are many questions about *"how we can make instalaltion on win7"*. Thatswhy i made one video tutorial which is mention *"How to install Oracle 11gR2 on Windows 7* Its avaliable at my blog: *http://heliosguneserol.wordpress.com/* Hope

  • Grouping Key Figures via Web item?

    Hi, in our webtemplates we would like to split the key figures (part of a structure) into two web items. Is it possible to split key figures, all part of one key figure structure, over two web items. Which webitem can handle this? Or does it require

  • 2Lis_11_VAHDR issue

    Hi I am uploading standard 2lis_11_Vahdr from ECC to BI7..I followed the following sequence: Datasource-> DSO--> Cube While creating infocube 0LOC_CURRCY, 0STAT_CURR and 0DOC_CURRCY does not transfer into incube from DSO. Even I tried to add 0currenc

  • OA Framework application deployment error

    Dear all, i am facing an error in OA Framwork application deployment step. when i use this command for importing OA Pages in server then one error is prompted: "Unable to initialize threads: cannot find class java/lang/Thread" my import command was l

  • G405s overheat and shutdown

    hi all.. i just bought this laptop 2 weeks ago.. since bought i got this overheat problem and tends to shut my laptop down.. my laptop BIOS right now ver 3.7 but still got this problem.. by using HWMonitor with idle states the temperature are around