Two parallel executions, calling a DLL function

Hello

Since this test takes about 6 hours to test my USE, I plan to use the parallel model to test 2 UUT at the same time in parallel.

I implement the test code as a DLL of CVI.

However, to my surprise, it seems that the steps that call a DLL function actually traveled in one series, not in parallel:

Test 2 power outlets if one enters and executes a DLL works, the other waits for the first to complete its operation and return. While the other runs on the same copy of the DLL, so that the DLL global variables are actually shared between executions.

So if a DLL will take 5 minutes to complete, two executions in the running at the same time take 10 minutes. This isn't a running in parallel in every way.

What I want and expect also TestStand, was to completely isolate the copies of these two executions DLL such as test two casings could run at the same time the same DLL function by arbitrary executiong their copy of the function, completely isolated from one another.

So they separated globals, discussions, etc., and two parallel jacks take 5 minutes to run a step, instead of 10.

Such a scenario is possible?

If not, how can I use my test in parallel (in truly parallel) when the use of 2-socket test?

(1) Yes, he'll call the multiple executions in TestStand calling into the same dll in memory the same copy of this DLL. Thus dll called in this way must be thread-safe (that is written in a way that is safe for multiple threads running the code at the same time). This means usually avoiding the use of global variables among other things. Instead, you can store the thread shows in local variables within your sequence and pass it in the dll as a parameter as needed. Keep in mind all the DLLs your dll calls must also be thread-safe or you need to synchronize calls in other DLLs with locks or other synchronization primitives.

1 (b) even if your dll are not thread-safe, you might still be able to get some benefits from parallel execution using the type of automatic planning step and split your sequence in independent sections, which can be performed in an order any. What it will do is allow you to run Test a socket A and B Test to another socket in parallel, and then once they are then perhaps test B will take place on one and test one run on the other. In this way, as long as each test is independent of the other you can safely run them in parallel at the same time even if it is not possible to run the same test in parallel at the same time (that is, if you can not run test on two Sockets at the same time, you might still be able to get an advantage of parallelism by running the Test B in one take during the tests in the other. See the online help for the type of step in autoscheduling for more details).

(2) taken executions (and all executions of TestStand really) are threads separated within the same process. Since they are in the same process, the global variables in the dll are essentially shared between them. TestStand Station globals are also shared between them. TestStand Globals file, however, are not shared between runs (each run gets its own copy) unless you enable the setting in the movie file properties dialog box.

(3) course, using index as a way to distinguish data access are perfectly valid. Just be careful that what each thread does not affect data that other threads have access. For example, if you have a global network with 2 elements, one for each grip test, you can use safely the decision-making of index in the table and in this way are not sharing data between threads even if you use a global variable, but the table should be made from the outset before start running threads , or it must be synchronized in some way, otherwise it is possible to have a thread tries to access the data, while the other thread is created. Basically, you need to make sure that if you use global data which the creation/deletion, modification and access in a thread does not affect the global data that the other thread use anyway in or we must protect these creation/deletion, modification and access to global data with locks, mutex or critical sections.

Hope this helps,

-Doug

Tags: NI Software

Similar Questions

  • What happens when two parallel process call the same VI in an FPGA?

    Hi all

    I was wondering, what happens when say two parallel processes call the same Subvi in an FPGA? I think that the FPGA would create two instances of the Subvi, not sure. Any point of view?

    Thank you

    Altras

    I don't know if the FPGA adds any ordinary special, but in LabVIEW rule and in LabVIEW Real-time, a VI by default is not reentrant.  Therefore, a process that is called when it is already in use is blocked and must wait.

    If the VI is reentrant, however, then you have two (or more) for the VI dataspaces, so that each can run independently.

  • How to call a DLL function that has need of an array initialized structures which can be written in by the DLL?

    I need to call the following function in a C DLL:

    __declspec (dllexport) int MSIL_EnumSpectrometers (SPECTROMETER_ID * spectrometers);

    where the only parameter is a pointer to:

    typedef struct
    {
    tank model [32];
    series char [32];
    Channel int;
    } SPECTROMETER_ID;

    Before LabVIEW 2011 I would use a CIN allocate the memory and call the function, but in LabVIEW 2011, the INC has been deleted and I have to use a library function node call instead. When I go to set the parameter, it seems that I need to set the type to "Adapt to the Type" and data for 'Pointer to data in table' Format, then pass an initialized array of SPECTROMETER_ID with the many elements he so the DLL can fill the table with data. (See the attached picture.) When I do that, however, it blocks LabVIEW desktop.  I guess it is because the DLL is corrupting the memory space of LabVIEW, but I don't see why, because I'm basically passing in a void pointer to an array initialized in the right size. Note that the first node of NSI returns the number of elements required in the table.  Anyone have any idea what I'm doing wrong here?

    In LabVIEW, when a table is in a cluster - cluster don't detain actually table but sort of a pointer that points to the table. If you need the cluster to contain 32 to 32 Add to the cluster. See the VI attached to how it's supposed to be done.

  • allocate memory and call the dll function that writes to the pointer

    Hello!

    I have a DLL that has a function as in the following example, I need to call from labview. In C, I need to allocate memory for data and of course the struct. I add the pointer and the length of the data to the struct and call the function with the struct. The function itself inserts values of the struct and affected memory. Someone at - it a working solution how this can be done with Labview?

    typedef struct Thestruct
    {
    UINT16 val1;
    UINT8 val2;
    UINT8 val3;
    DataLength UINT16;
    UINT8 * data;
    } T_Thestruct;

    MY_API status MY_API_CALL udaReceive (handle, T_Thestruct * args);

    I tried in labview (see photo), but I only got values inside the structure as well as the 1097 error, reserved memory included values as before.

    OK, I found the soluton to my own problem. Alignment on the struct must be corrected in Labview. There must be a value between dataLength 2Bytes dummy and the pointer.

  • Call the DLL function with a pointer to a complex structure

    Hello

    I try to call a function by using COLD LAKE. My problem is the function parameters that I'm trying to access.

    Here is the function and its parameters:

    typedef struct _BAR_INFO
    {
    ULONG dwSize;
    ULONG dwFlag.
    } BAR_INFO, PBAR_INFO;

    typedef struct _DEVICE_INFO
    {
    ULONG dwBarNum;
    BAR_INFO BarInfo [6];
    } DEVICE_INFO, * PDEVICE_INFO;

    Int GetDeviceInfo DLLIMPORT)
    unsigned int CIH.
    PDEVICE_INFO pdevinfo
    )
    {
    ULONG i;

    If (DFR > = DevNum)
    Return PCICORE_DEVICE_NO_FOUND;

    If (DevTable [JC]. DevHandle is NOTHING)
    Return PCICORE_DEVICE_NO_INITIALIZE;

    if(pdevinfo == null)
    Return PCICORE_INVALID_PARAMETER;

    pdevinfo-> dwBarNum = DevTable [JC]. DevInfo.dwBarNum;
    < pdevinfo-="">dwBarNum; i ++)
    {
    pdevinfo-> .dwFlag BarInfo [i] =
    DevTable [JC]. DevInfo.BarInfo [i] .dwFlag;
    pdevinfo-> .dwSize BarInfo [i] =
    DevTable [JC]. DevInfo.BarInfo [i] .dwSize;
    }

    Return PCICORE_SUCCESS;
    }

    As an attachment, there is the Info.vi device Get trying to access this feature. The code crashes when the function is called.

    I have probably not pass parameters of data properly to COLD LAKE.

    Thank you for your lights.

    An array of fixed size in C is equivalent to a cluster of LabVIEW that contains the same number of identical items, replace the table with a cluster. In addition, structs are always passed by reference and the C function expects a pointer to a structure, you don't need to unbundle. Skip the cluster to function as a single parameter. Try the attached revised version of your VI.

  • Call the DLL function with pointer to a simple structure

    Hello

    I try to call a function by using COLD LAKE. My problem is the function parameters that I'm trying to access.

    Here is the function and its parameter:

    typedef struct {}
    int major;
    minor int;
    review of int;
    build int;
    } VersionNumberType;

    int Comm_BTE_softVersion (VersionNumberType * pVersion)
    {
    BYTE ByBuffer [2048];

    If (!.) Comm_BTE_readYMem (byBuffer, COMM_BTE_TX14_SOFTVERSIONADDR,
    COMM_BTE_TX14_SOFTVERSIONSIZE))
    {
    return FALSE;.
    }

    //. process the response
    pVersion-> major = (int) (byBuffer [0] & 0xFF);
    pVersion-> minor = (int) (byBuffer [1] & 0xFF);
    pVersion-> revision = (int) (byBuffer [2] & 0xFF);
    < 8)="" )="" |="" ((int)="" (="" bybuffer[5]="">

    Return TRUE;
    } //. end Comm_BTE

    As an attachment, there is the Version.vi soft Comm BTE who try to access this feature. The code crashes when the function is called and labVIEW is closed.

    I have probably not pass parameters of data properly to COLD LAKE.

    Thanks for help.

    Kind regards. NewCLAD.

    Everything is configured properly EXCEPT the digital representation of the values in the cluster. They must match int, which is likely 32 bit on your platform. They are your VI, U8.

  • DLL function called change of entry

    Hello world

    I know that it is very basic; but I am not by my own. I am very new to LabVIEW and was not able to find a solution in the forum.

    I want to call a function in a DLL, every time when I press a button; but unfortunately, the function is called only when starting.

    So, how can I call a DLL function on a change of some of the entries?

    I have attached a screenshot. I tried the stuff. It did not work. Now, the function is called twice during startup.

    Thanks in advance and best regards,

    Chris

    If you want to call anything with a button, use a structure of the event with a value change event.

    I would recommend that you take one of the free LabVIEW tutorials available on the site and see examples of delivery - help > find examples.

  • repeatedly calling a dll that contains a loop

    I would like to call a dll function that contains a while loop. This copy of the data to a buffer loop a signal command "on" is true:

    void Get (double * x, double * y, double z *, double *, double * P, double * R, int on)
    {
    int index is Index - 1;.

    while(on == 1)
    {
    If (index > = buffersize)
    {
    index = 0;
    }
    * x = buffer [index]. Position [0];
    * y = buffer [index]. Position [1];
    * z = buffer [index]. Position [2];
    * Y = buffer [index]. Angles [0];
    * P = buffer [index]. Angles [1];
    * R = buffer [index]. Angles [2];
    index ++;
    }
    }

    I want to call this function from dll once 'on' is set to true and it ends once it becomes false. I also want to be able to 'on' on and outside, so that it can copy data from the buffer when I want to. I could not find a way to do it, and whenever I walk through the program it does not 'stick' when the Get function is called (i.e. the while loop inside the GET is running), as I would expect.

    Thank you for any assistance.

    I guess 'Index', 'buffersize', etc., is static variables?

    In any case, once you called the function expected of LabVIEW for the function to fill. You can not dynamically pass a new value for "on" during the execution of the function. Note that this is not a question of LabVIEW. The same would be true when using this DLL from any other programming language. What you need to do is to have the function use static 'on' and then provide a separate function to set this value. Note that you must also configure the COLD LAKE to be "incoming".

  • There is a configuration option that allows the parallel execution of sub vi?

    I'm trying to run a vi in teststand has two parallel execution paths. A path under vi implements the trigger and wait for data from a module scope, while in the other lane, I'm starting a power supply. The power waits until the scope is armed and runs.

    It works as a standalone vi. When I try to run this vi in teststand he works the first vi scope and then runs the power supply. Of course vi opportunities get to expiration and outputs and data are not met.

    I tried a number of methods of synchronization, and although they seem to work standalone, as soon as I try them in Testsatnd I have this problem.

    I am new to teststand and I was wondering if there is some configuration config I missed which allows a vi like this to run as he's independent.

    I have a number of simple screws that run as planned, but this one left me speechless.

    I had to split these screws but would really prefer to have them in the same vi.

    (The latest versions of teststand and Labview running)

    Henry

    hkroker,

    It is a known problem. Please refer to the following KB to help solve your problem.

    - Parallel blocks run sequentially why does my LabVIEW VI when it is called from TestStand?

    Concerning

    Anand jegou

    National Instruments

  • When to call DSDisposeHandle when you have a DLL function acting as a dynamic data DS source extensible?

    Hello

    I have a dynamic function DLL acting as a data source within a LabVIEW application (see attachment) - I use DSNewHandle to dynamically allocate an array 2D handle storage via the Manager memory LV for arrays of arbitrary in application size data. I had assumed that these blocks of memory would be willing (Magic) when appropriate by the LabVIEW built in blocks that are sitting downstream, however, is not the case for treatment and the system LabVIEW memory usage continues to increase until you quit LabVIEW environment (not just if the offending application is stopped or closed).

    So my question is how and where to mop up the table used for buffers in the treatment of the application of the chain and how do I know when the buffers are really exhausted and not be re-used downstream (for instance two 2D paintings are first grouped into a 2D complex table by the re + im at the operator complex labview - is data memory out of this totally different stage of entries or is - a) modified version of the entry tables - if they are totally different and 2D to entry tables are not wired in all other blocks why the operator not have input data banks?)

    Maybe Im going to this topic in the wrong direction have the DLL data source dynamically allocates space data tables? Any advice would be welcome

    Concerning

    Steve

    So instead of doing:

    DLLEXPORT int32_t DataGetFloatDll(... , Array2DFloat ***p_samples_2d_i, ...)
    {
        ...
    
        if ( p_samples_2d_i )
        {        // *p_samples_2d_i can be non NULL, because of performance optimization where LabVIEW will pass in the same handle        // that you returned in a previous call from this function, unless some other LabVIEW diagram took ownership of the handle.        // Your C code can't really take ownership of the handle, it owns the handle for the duration of the function call and either        // has to pass it back or deallocate it (and if you deallocate it you better NULL out the handle before returning from the        // function or return a different newly allocated handle. A NULL handle for an array is valid and treated as empty array.
            *p_samples_2d_i = (Array2DFloat **) DSNewHandle( ( sizeof(int32_t) * 2 ) + ( sizeof(float) * channel_count * sample_count ) );
    
            // Generally you should first try to insert the data into the array before adjusting the size        // the most safe would be to adjust the size after filling in the data if the array gets bigger in respect to the passed in array        // and do the opposite if the adjusted handle happened to get smaller. This is only really important though if your C code can        // bail out of the code path because of error conditions between adjusting the handle size and adjusting the array sizes.        // You should definitely avoid to return from this function with the array dimensions indicating a bigger size than what the        // handle really is allocated for, which can happen if the array was resized to a smaller size and you then return because of errors        // before adjusting the dimension sizes in the array.         ........        (**p_samples_2d_i)->Rows = channel_count;
            (**p_samples_2d_i)->Columns = sample_count;
        }
    
        ...}
    

    You should do:

    DLLEXPORT int32_t DataGetFloatDll(... , Array2DFloat ***p_samples_2d_i, ...)
    {
        ...
        MgErr err = NumericArrayResize(fS /* array of singles */, 2 /* number of dims */, (UHandle*)p_samples_2d_i, channel_count * sample_count);
        if (!err)
        {        // Fill in the data somehow
           .....       
    
            // Adjust the dimension sizes        (**p_samples_2d_i)->Rows = channel_count;
            (**p_samples_2d_i)->Columns = sample_count;
        }
    
        ...}
    
  • Why the DLL function performed by call library node fails when the Vi is reopened?

    Development system

    OS: Windows XP

    LabVIEW: version 10.0

    DLL: Custom

    Compiler: Visual C++ 6.0

    Function prototype: __declspec (dllexport) const char * test (void)

    We have developed a DLL to use.  Compile the DLL itself.  The DLL includes a function test.  The test function validates the functional capabilities of the DLL.  I followed the examples online, and I used the tool to import shared library in LabVIEW.  The screw created use the call library node.

    When I create a VI by calling the function in the DLL test customized by using the call library node the VI runs the test DLL function flawlessly.  I close the VI.  When I re - open the VI and run it, I get an error code of the DLL.  However, if I go on the schema and define the path of the DLL in the library call Configuration node once again the VI then runs the test DLL function perfectly again.

    I have set the path of the DLL in the library call Configuration node everytime I open the VI.  The examples that I downloaded from the community don't require this.  What could be the missing DLL?  What Miss me?

    I solved the problem.

    I had create the DLL by using the following steps for VC 6.0:

    1. new project

    2. Select the Appwizard (DLL) MFC

    3. Select the regular DLLS using the MFC shared DLLS

    4 Yes for source file comments

    5 finishing

    The DLL must be on the VI search path.  The easiest way was to have the DLL in the same directory as the VI.

  • How to properly call modal vi function in the C dll

    I have a labview function that takes a string as input and passes out when the user clicks OK in a 2 button dialog box. I have built a dll and then calls the function from a C++ environment by using the LoadLibrary function. If I set the Panel before shows the default settings and NOT modal the vi is displayed correctly but the dialog box box does not work. If I put the Panel before the vi to modal then vi front panel display correctly, therefor there I find that the dialog should be modal in his view.

    My question is about C++ How can I call a dll that displays a Modal form correctly? or how can I change the dialog box in modeless behavior / defect that can be done to the face before of the vi?

    Thanks in advance for any help.

    Hi, thanks for yor reply.

    The dialog box displays only partially. No, I have not tried the express vi, but I did create a vi to behave like a dialog box 2 button

    allowed me to define it as modeless. It also displays only partially.  I since first announcement also tried to run the dll also using labview and teststand to call the dll, in both cases the dll load and behaves correctly, the dialog box appears correctly.

    This suggests that the problem is with the C++ code but not being is not a very experienced C++ programmer I don't know how to debug the problem more far.

    Any help is highly appreciated.

  • Call the library function does not find the DLL in the directory where are my LLBs

    I'm using LabVIEW 8.6.  I have a set of screws in several LLBs.  All LLBs located in a directory.  Most of my screws is wrappers for the functions in a DLL.  I was told to put my DLL in the directory where are the LLBs, and apparently this is how the previous programmer has worked (using an earlier version of LabView).

    In the configuration of the library call, I've specified .dll without path.  (This is how we want our screws are an API that will integrate other programmers, so I don't know where they put things and I can't use absolute paths).

    When I insert the VIs in LabVIEW, LabVIEW can not find the DLL and wonder of spotted.  It's just that here in the directory with the LLBs and when I double click on it, everything works fine.  However my absolute path to the DLL now appears in the library to call configuration, and we don't want that.

    Does anyone know how to make this work?  I guess the location of the screw (or LLBs, in this case) should be the current directory and thus Windows search there for the DLL.  However, it seems that this is not the case (in the least, in the latest version of LabVIEW).

    Thank you.

    Batya

    Well someone using your library should not have to dig into your screws and do it all on his own. Instead your library must wrap that and hide disorders it altogether.

    The cluster of error has been added when the dynamic path option has been added. It is not useful hide this error output, so it's always there. As well as the dynamic path, there was the improved error handling added the CLN. One of them is that the level of verification when calling function errors (exception handling) can be specified. I guess that some of these options may generate an error code instead of bring up a dialog box, as they did before and that the output of error code can be useful even in the case of static calls.

    As to what you want to do, I would have long managed that with a DLL that has essentially the same functions as your other wrapper DLLs and an initiliasation function that returns a pointer to a structure of functional distribution based on the actual DLL you want to call. Quite like what an object-oriented function dispatch table is. Then, when your interface initilising you call initialize function and specify the device interface/type that you want to use and after that all other functions take a pointer extra function parameter expedition as the first parameter, in addition to the parameters of the real function. This dispatch function pointer would be just a pointer to a structure that contains the table of function for this interface pointers and the sake of LabVIEW would simply be an integer of size pointer.

    The wrapper function then checks the pointer structure validity send feature and call the actual function with the remaining parameters. It is a C programming and may require a planning and desigining the different interfaces to facilitate this kind of technique of the expedition, but it will certainly pay to long-term and make your library even can be used in previous versions of LabVIEW, so that VB etc. without delicate dynamic loading in the level high, programming environment.

    Rolf Kalbermatter

  • Problem calling seconday DLLs in labview

    Hello

    I'm using Labview 8.6 for my application. The application calls a dll developed in vc ++ (main dll).  During execution of the application, the main dll(vc++) calls another (secondary dll) developed in vb 6.0 dll.

    During the process, the main dll sends data to secondary dll to display data in a pop-up window. After getting the user recognize the display, the vi application stops.

    When the application runs first time (the vi running first time after labview open), the data sent by the main dll are updated in view of the secondary DLLs. But, for the second time from new data of the main dll not are not updated in view of the secondary DLLs.

    Once again, after the closure of the vi and quit labview, if I open and run the vi, then the data of the main dll are updated in dll secodary display. But the maindll data must be updated in the secondary dll without leaving labview.

    I use "Function Call Library" to call the maindll.

    Can someone please give the remody to this problem...

    Thanks in advance.

    Swamy.

    Is - this two dll to reside in the same physical directory as your main vi? They are included in your project?

    -AK2DM

  • Problem with the help of DLL functions

    Hello.

    I'm writing a DLL that calls the functions of a DLL camera and them ends and passes of LabView. I wrote some code of practice and the dll of passage of functions and events with Labview and LabWindows/CVI DLLs, so I like to think I have a reasonable understanding on what I'm trying to do. However I keep getting errors in calling the functions of DLL functions camera I want to use in my DLL.

    I have two functions in the camera DLL, XC_AddImageFilter, and XC_RemImageFilter, I would like to wrap and put at disposal in my DLL. When I compile I get the following errors:

    2 link project errors, Undefined symbol '_XC_AddImageFilter' referenced in "ImageFilter.c". Undefined symbol '_XC_RemImageFilter' referenced in "ImageFilter.c".

    I tried to tweak the prototypes in my header file and the change in functions but nothing I try seems to work. I connected the camera DLL in my project in a way that was previously successful with another practice DLLs and I browsed this forum for similar problems, but I can't seem to find a soloution.

    Thank you for taking the time to read this. I hope that you will be able to help me with my problem.

    PS I had problems to join my code so I put an extension .txt at the end and apparently has worked so please forgive the suspicious file extensions.

    Sorry!

    I do not understand the Labview.lib file which is why Labview functions weren't working! Duh!

    #begginer errors!

Maybe you are looking for