YAQ on multithreading

I'm sorry, but I still have another question about multithreading and related functions in the library of utilities of the CVI. In the example of aid, if one of the graphic panels is left, the QuitUserInterface function is called. This led to a call to DiscardPanel, hence the graphic Panel is ignored. In the main thread, the thread pool service ID is released. But what happens to the thread? No CmtExitThreadPoolThread is called to return the thread to the thread pool. It is automatically "as available" again at the pool when the pool function ID thread is released? Or if not when?

The CVI help said: in the thread from the pool, call CmtExitThreadPoolThread to ensure that the thread is returned to the pool safely. So why this function is not called in the example program?

Thanks again,

Wolfgang

(I postponed convert my program of multithreading for a long time, but now I've made my decision, and accordingly I am in the middle of a major confusion...)

This quote from the help is a bit out of context. It is using the function for CmtTerminateThreadPoolThread, and it serves to explain a safer alternative to call CmtTerminateThreadPoolThread.

As a general rule, you should no need to call CmtExitThreadPoolThread. If your thread function returns normally, the thread will be going back in the thread pool, ready to be reused. CmtExitThreadPoolThread is designed for things like exceptional control flow. You can think of it in the same conditions as the appellant longjmp (who, in fact, is exactly what he does under the hood).

Hope that helps.

A. Mert

National Instruments

Tags: NI Software

Similar Questions

  • 13 Firefox works in multithreaded mode and it can use the quad-core processors?

    When you buy a new PC, we choose between dual core vs quad core processors, and some people claim that Firefox work mode multithreaded mulch and treats each tab in a separate process and may fully use the advantage of a quad-core processor. Is this true?

    Firefox does not treat each tab in a separate process. If this can be a function in the future, I don't know of any plans to introduce any time soon. Obviously, buying a quad core processor will be significantly faster than a dual core, and your browser is usually less consume a lot of resources than other programs. I would not use it as your buying decision. Firefox will work just as well on a dual-core or a quad-core, but windows and other programs will work better with 4 cores.

  • Multithreading and partitioned shared memory

    Hi all

    I'm having no success with this problem multithreading (simple?) on my processor core-i7, using CVI 9.0 (32-bit compiler).

    In the snippets below, I have a structure of node 5 integers, and I use 32 calls to calloc() to allocate space of 32 blocks of 128 * 128 nodes (16K) and store pointers returned in a table as a global var.

    Size in bytes of the nodes = 20, size in bytes of the block = (roughly) 328KB, total allocated size in bytes = (roughly) 10.5 MB.

    I have then spawn 32 threads, each of them is passed a unique index in the pointer_array of 'node_space' (see code below), kind, each thread handles (read/write) a block separated from K 16 knots.

    It must be thread-safe and multiply by the number of threads because each thread is addressing a different memory block (with no overlap), but not multithreading go more quickly (maybe a little) to a single thread.

    I tried different sizes of thread pool, filling of the nodes to the limits of 16 to 64 bytes, all to nothing does not.

    Is this a problem of band bandwidth memory due to the size of the tables? Each thread is somehow loaded the whole 32 blocks?  Any help appreciated.

    struct node

    {
    unsigned int a;
    unsigned int b;
    unsigned int c;
    unsigned int d;
    unsigned int e;

    } ;
    typedef struct lymph nodes;
    typedef nodes * Node_Ptr;

    Node_Ptr node_space [32];          / * pointer to table in 32 separate blocks (loaded via individual calloc calls for each block) * /.

    .... Spawning wire...

    for (index = 0; index)< 32;="">

    CmtScheduleThreadPoolFunction (my_thread_pool_handle, My_Thread_Function, & index, NULL);

    Hello CVI_Rules,

    It is difficult to answer your question because it depends on what you do in your thread function. Given that you do not see any speed upward in your program when you change the number of threads in your thread pool, you are done as well (or all the work) in each thread, serialize your threads with locks, or somehow slow down execution of each thread.

    Your basic configuration seems fine. You can simplify it slightly by moving the nodes directly to your thread function:

        for (index = 0; index < 32; ++index)
        {
            CmtScheduleThreadPoolFunction(pool, My_Thread_Function, node_space[index], NULL);
        }
    
    ...
    
    static int My_Thread_Function(void *functionData){    Node_Ptr nodes = functionData;...
    

    But this will not affect performance.

    Things to look at:

    1. Check that you're really work only on a subset of node space in each thread, you are passing and receiving the correct node space in each thread and you work only on that one.
    2. Verify that you do not have locks or other synchronization in your program. It seems that you do not have because you have designed your program so that it would not need any. But check anyway.
    3. Check that you do not have something useless in your thread function. Sometimes people call ProcessSystemEvents or ProcessDrawEvents because they feel that it makes the user interface more responsive. These two functions are expensive (all about 20 ms per call, I think). So, if you call these functions in a loop, with a fixed number of iteraction on all threads, and if the actual calculations are relatively fast, then these functions can easily dominate the runtime of your program. (There aren't necessarily those functions, it may be others. "These are just examples).
    4. Show and explain your code to a colleague. Sometimes, you don't see clearly until you show someone. Or they may have noticed something.

    Apart from this, can you explain what you are doing in your thread function so that we can have a better understanding of your program and what might inhibit parallelism?

  • Multithreading and interactions with instruments

    I have to start by saying that I'm not a great programmer. I build an instrument that requires a computer interface, and I learned how to program at the time of writing the program, for most documentation work (which means I have re-written program one half package of time I learned new things like how to define data structures and so on).

    My question is about multithreading - in my application, I use the GUI to write a series of instructions, and then I press a "Start button" which loads the instructions on a Board that interprets and outputs some call digital logic by the precisely. In addition, if specified, the button 'start' begins a task DAQmx that takes a trigger of my Board and acquires data. As these scans can take a long time, it is better for me to run in a separate thread. I also try to run an additional thread that queries the Board of Directors for its status - if it is running, waiting for a trigger or stop - and updates a control LED to reflect the State periodically. The problem I have is that programming function, the Board of Directors and the audit of the State function has some overlap, which I imagine is the reason why I'm the General Protection faults.  I read on the Thread hangs and Thread-Safe queues, but those who seem to be especially on the transmission of data between threads. Ideally I would be able to make sure that two threads do not call the same function at the same time - how would implement this?

    In addition, I don't know if it is a problem of the two threads calling the same function at the same time (I dunno if it of a problem or not), or if the problem is the fact that when I call these functions, they need to access the USB interface and there may be some sort of conflict between them.  I'm really hitting a wall here because I think that I don't have a solid understanding of the operation of allocation memory and battery function.

    Hi Paul, from your description, it seems very likely that you have problems with contemporary access to the same resource from multiple threads, which could explain the GPF you receive.

    Thread locks are a common way to handle such situations, because they can allow a single thread to protect it from another thread any access to the shared resource.

    Locks are used is:

    1 create a lock before you need to use it (possibly at the start of the program)

    2. when a thread needs to access the USB port to communicate with the instrument, it must call CmtGetLock to block access from other threads: If the lock is free, it is acquired by the threads. If it is already owned by another thread, the thread waits on the CmtGetLock until the bolt is free

    3. once a lock is finished using the shared resource, it must call CmtReleaseLock to permitt the access to the resource from other threads

    4. at the end of the program, destroy the lock

    If you do not want to stay frozen in CmtGetLock of a thread there is a function in the library if the lock is free or not, so that you can stay in a loop waiting for the lock to be free, but with the wire still alive and able to continue its work (still without access to the shared resource (, of course).

    It is crucial that acquired locks are always released, otherwise the other threads will be permanently excluded from access to the shared resource: this review is particularly important when adding threads management, because you must be sure to release locks acquired even errors, when a policy of the commune is to jump to a label inside the error handling function and it is possible that a lock is held acquired errors.

  • Safe multithreading NI FPGA Interface C API?

    Hello

    I use the FPGA C API interface to communicate with the software labview on my FPGA OR. Some calls take a while to run, for example, reading on a FIFO so long timeout. So far, I assumed that the interface was not safe multithreading. It has now become annoying given the timeout problem described above. Try simply was not good, it can take a long time to create a "collison.

    Is the FPGA interface safe multithreading C API? Or, more specifically, the functions of FIFO reading can be called in parallel with read/write variables on the FPGA?

    Thank you.

    Hello MKAP,.

    It has been a while since I used the NI FPGA Interface C API, but it is what I remember and seem to be able to remember (and also found in the documentation):

    Functions related to the unloading and loading of the library are not thread-safe:

    http://zone.NI.com/reference/en-XX/help/372928D-01/CAPI/functions_required/

    On itself, this should be a problem:

    Your application should require that the NiFpga_Initialize is called before any other function associated with function calls NIFpga.

    In a similar way that unloading (NiFpga_Initialize) lof NiFpga brary should occur only when you are finished using it.

    With regard to multithreading, you must also keep in mind its mono-thread interrupts IRQ (if you plan to use them):

    http://zone.NI.com/reference/en-XX/help/372928D-01/CAPI/functions_interrupt/

  • Function calls multithreaded suddenly causing blockages

    I'm having a problem with function calls from multiple threads. There are two threads that everyone calls a function called save_program, including a DDCChannelHandleGroup and and a certain structure "show pulse" moved. The problem I have is that after that I called him save_program of one of the sons, it crashes when I try to call from the other thread. There are three contexts for this - two in the main thread and the other in the thread of data acquisition.

    If I call the save_program of one of the contexts in the main thread, the program crashes when I try to call it in the thread for the acquisition of data and vice versa. No problem since the two contexts in the same thread. I put a breakpoint in the function call and the first part of the executable code in save_program (declaration of variable initialized to NULL), and the program freezes between these two breakpoints. I checked and always executed entirely complete in each of the threads AND the call of CmtExitThreadPoolThread() also runs very well. I also locked up all instances of save_program in CmtGetLock/CmtReleaseLock calls without success. Oddly, these calls used to cause no problems with the exact configuration of multithreading even. I don't know what has changed.

    Hi PaulGanssle,

    It is very possible that you have already encountered a problem experienced in LabWindows/CVI where transactions must be completed before calling SaveFile.  I have included a link below that talks a little more about this problem.

    http://zone.NI.com/DevZone/CDA/tut/p/ID/12323#281013_by_Category

    It is a question that has been reported and is managed by R & D.  From now on, it is not a fix available but I hope we can find a work around that will work for your application.

    Please let me know if you have any other questions.

    Kind regards

    Kyle S

  • I am looking for use multithreading to run several tests in parallel on a single object to measure.

    I wait with multithreaded several tests in additional on an object to measure.  I looked in the main site and all the examples are in zip files which seems to me not being able to download successfully on the site.  Is someone there examples of files or whitepapers on the subject that I can consult?

    put a test in a sequence of void.  Then call this subsequence using New Thread as execution Options:

  • First time multithreading in Labview

    I learn Labview and this is my first project. I expect this behavior from my attached VI. I thought that both the indicator will increment asynchronously if I ask to wait for Member States inside the while loop. I thought indicator 1 will increment the thread will go to sleep to 1000ms and in the increase of the 2 indicator average time and he goes to sleep and so on. Please, need help in understanding multithreading with Labview.

    By plugging the output of the judgment of the upper loop of the lower loop, the lower loop is waiting for the top loop fill and send the value before it starts exectuing.  Try this:

  • Multithreading tcp connection

    Hello

    I build a labview server that communicates with a java client.

    The work of communication, but I have 2 problems:

    -Labview writes only the channel over tcp, so I threw Double chain, but when I try to read it reads a bad value. Anyone know what kind of flow, I can use in java?

    -How can I get a multithreaded server? After the first reading I have to wait for other events, that will happen during the execution of the program.
    I tried with two while loop with 2 tcp listening on different ports, but it did not work.

    Thanks for your help,
    Veronica


  • With the help of VISA Write in parallel loops (multithreading)

    Hello

    I got the idea to set up four parallel loops on a quad core with four EHR via serial port independently. I use the PXI-8430/8 and I was told that an independent operation of ports is possible.

    What I did was simply to put in place four parallel for loops consisting only of a single entry VISA. With the help of the Tools > profile > find parallelizable loops, they gave me the following warning

    This loop For may or may not be safe to parallelize. Warning (s):
    -A node in the loop For can have side effects.

    This means, that the pilot VISA screws are not suitable for multithreading? With the help of LV2010

    Thanks for your comments!

    See you soon

    Oli

    Here's some good reading on paralleled for loops.

    Regarding the caveat, it's just that - a warning. If you write commands on a device and orders must be received in the order then you cannot parallelize the loop. If the order does not matter then go ahead. But in the case of VISA wrote that a parallelized loop going not buy you anything. They are intended for operations of calculation intnesive.

    Just stick to four loops.

  • Why my reference FFT VI does not see gains multithreading?

    I am using a multicore processor to speed up the calculation of 32 FFT by running in four parallel threads, as shown in the code example below image. However, the difference in performance between single and multi-threading is only approx. 10% even on a Core 2 Quad CPU.

    I tried a few things, for example by placing the table split and merge functions or graphic waveform, outside the timed section, but this has very little effect - the main delay persists with screw FFT. These screws are already implemented reentrant, but somehow always do not perform well at the same time. Why?

    Can someone show a better performance gain in a similar VI? I'm using Labview 7.1, using pictures instead of a VI for the answers would be greatly appreciated!

    Thank you!

    Hello

    Thanks for your reply. In fact, I found the solution. Rather already internal multi-threading, the Express VI has done exactly the opposite, he broke internal capacity of multithreading, including several side bolts that were not reentrant. This means that the Global Spectral VI analysis Express is not reentrant and accelerate properly on a multi-core CPU.

    My solution was to dig in the Express VI until I found the most basic levels VI (DLL function calls etc.), which have been completely re-entrant. By extracting these and by simply registering this essential code as a new, fully environment sub - VI, I was able to unlock the potential full multi-core. My reference FFT VI runs now 5 times faster, simply by replacing the Express VI with the FFT VI stripped of myself.

    As a courtesy, I enclose my new, 5 x faster multi-core FFT VI.

    It evolves on an Intel Core 2 Quad CPU as follows:

    LabVIEW Spectral Analysis VI Express (single or multiple instances): 1 x speed

    Multi-Core FFT VI (single instance): 2.3 x 2.4 x Faster

    Multi-Core FFT VI (double instance): 3.7 x 4.0 x Faster

    Multi-Core FFT VI (quad instance): 4.8 x 6.1 x Faster

    Multi-Core FFT VI (instance octo): x 4.8 to 6.1 x Faster (could probably use a 8-core see benefits)

    Here are the internal features of the VI of FFT multi-core Lite:

  • OS 6.0 + sqLite Multithreading and synchronized

    I am trying to create an application that has multiple threads running in the background. In total, there are 5 wires including the UI thread and everything would be publishing and reading of data.

    I created a static final object to be used for the synchronization.

    For each SQL statement, I join in

    synchronized (GlobalVariables.lockObject) {}
    Create or open the database
    CREATE statement
    Prepare surveys & run
    Close the database
    lockObject.notify)

    }

    In principle I think it should work in multithreaded environment. However, it doesn't. It works for the user interface thread but then it waits indefinitely to prepare the declaration for the background thread to random places in my code and is not go forward until I take action in the UI thread that makes a database operation.

    This works perfectly in OS 7.0, but does not not in 6.0 Simulator and devices.

    Can someone help me out here? I'm really stuck here the last 4 days.

    Thank you

    I found the solution.

    Apprantly in my case, I had a UI element invalidating his element parent in the paint method.

    So IU went into an infinite loop and since in OS 6.0 UI methods takes a higher priority and the thread is kept on until that user interface methods are completed he was trapped in the thread.

    Thank you to everyone who reads this post and tried to help me.

  • How to use pthread_create for multithreading in C/C++?

    Goal: Create two threads at the same time to collect and process the data.

    Error: Buffer problem. A [i] when I is increased, the accident will be held later.

    Question: How to use pthread_create for multithreading in C/C++?

    or you know any related document, I can read?

    Mini code:

    pthread_t A, B;

    void * rawacceleration(void*);
    void * featureacceleration(void*);

    pthread_create (& A, NULL, & rawacceleration, NULL);
    pthread_create (& B, NULL, & featureacceleration, NULL);

    Thank you for your attention.

    Sorry guys.

    It is a buffer problem.

    Try i = 0 to [i]. The problem is resolved.

  • SR 3-11038905651: would like to know if Autovue 20.2.3 supports the multithreaded Client

    We use the Autovue API to generate PDFs. When we call the program side server that generates PDFs of Multithreading program is out error.

    Please suggest if we can use the client code multi-threaded.

    Thank you

    Siva

    Could you please clarify your question: all Java programs are multi threaded and AutoVue 20.2.3 is no exception

    Now, since AutoVue isn't only multithreaded, but some of the API are asynchronous (for performance reasons)

    If you need to synchronize the actions, you must consider and properly plan your actions (listening to the generated events) to avoid the substitution of previous work

    In an attempt to answer your question

    If your question is if you can invoke all the API in order and get the right result, the answer is no, some of the calls are asynchronous (then ' setPage ',...)

    If your question has been if several threads with separate and different applications will be processed in their own context, well the answer is also no.  There is no local thread context, everything is distributed within the VueBean object.  If you plan to do, you will need a local instance of thread of AutoVue (JVue applet) or VueBean to deal with.

  • start of 12 DB in the configuration of multithreading without knowing the sys password


    Hello

    I have a test of 12cR1 (12.1.0.2) oracle database in an AIX environment. I wanted to try the Unix 'multi-threading' on the machine architecture, so I did everything excpet creating the password file before you shut down the database where the init.ora file has been modified (by adding threaded_execution = TURE).

    NOW I'm stuck, because once you enable multi-threading OS authentication not working anymore.

    You must provide the password for SYS explicitly, the problem I know not the SYS password and now cannot start the database!

    any suggestion or help?

    The problem is solved by following the guide in the following link: http://www.dbi-services.com/index.php/blog/entry/multithreaded-12c-and-connect-as-sysdba

    Kind regards

Maybe you are looking for

  • I have the most recent version lines of firefox, but my gmail said I did not. Help, please!

    I have version 19.0, but when I try and open onto gmail, it keeps sayting we don't have browser lates and update it please. I HAVE the latest firefox. The same thing happens when you try and open our msn and e-mail

  • Discount to zero number clip

    Sorry if this has already been answered, is but possible to reset the number of clip without reset camera full? Clear the SxS card does not help so I assume that the numbering is retained in-house. A full reset for each session is a PITA. Jack F5 Syd

  • Wireless receiver 3.1 Desktop device driver

    Hi all You just bought a Microsoft Wireless Laser Desktop 3000.  I installed the software that came with it.  However, my Windows XP Pro SP3 computer not recognize the receiver.  He keeps trying to install a device driver.  I looked in Device Manager

  • How to merge e drive with drive c?

    I have three partitions in my hard-c records, d and e.i don't know why e is here. Now the problem with me is that drive C less than 150 MB of free space and E drive has more than 10 GB of free space. I don't want an E drive and so I want to merge wit

  • Sleeping VPN tunnel

    Hi all I have an ASA 5510 with an active and functional l2l IPSEC tunnel. Now, I need to set up a "tunnel VPN asleep" which will have a different counterpart and is not active and no traffic is passed through this tunnel. Someone has done this? Thank