time-shifted calling of DLLs

This is a discussion on time-shifted calling of DLLs within the C++ Programming forums, part of the General Programming Boards category; Hey folks, i have issues calling 2 dlls (DLL1 + DLL2) from another DLL (EXPORT). The situation is: The main ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    13

    time-shifted calling of DLLs

    Hey folks,

    i have issues calling 2 dlls (DLL1 + DLL2) from another DLL (EXPORT).

    The situation is:

    The main DLL "Export" calls 2 other DLLs within its function.

    You can set a communication interval for the main DLL (e.g. 0.01s)

    but the 2 DLLs to be called should not be called at the same rate.

    (e.g. DLL1 should be called at 0.01s, like the main dll, but the DLL2 should be called at 0.1 s)

    The Code (only necessary parts without time-shift) looks like this:

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <windows.h>
    
    #define _USE_MATH_DEFINES 
    #include <math.h>
    
    typedef void (_cdecl *CTRL)(double*, double*);
    typedef void (_cdecl *INIT)(double*, double*);
    
    double inputarray1[101];
    double inputarray2[101];
    double outputarray1[101];
    double outputarray2[101];
    
    int counter;
    
    extern "C" 
    {void __declspec(dllexport) __cdecl EXPORT(float *var1,int *var2, char *var3, char *var4, char *var5);}
    
    void __declspec(dllexport) __cdecl EXPORT(float *var1,int *var2, char *var3, char *var4, char *var5)
    
    {
    
    HINSTANCE hinstlib_dll1= LoadLibrary(L"dll1.dll");
    HINSTANCE hinstlib_dll2= LoadLibrary(L"dll2.dll");
    
    call_dll1=(CTRL)GetProcAddress(hinstlib_dll1l,"CONTROL");  
    
    call_dll1(inputarray1, outputarray1);                                   <--- Function CONTROL in DLL1 should be called at 0.01s rate
    	
    call_dll2=(CTRL)GetProcAddress(hinstlib_dll2l,"CONTROL");   
    
    call_dll2(inputarray2, outputarray2);                                   <--- Function CONTROL in DLL2 should be called at 0.1s rate
    
    }

    So I think the best would be to set the communication interval to 0.01s to fulfill the calling convention for DLL1 and using a counter the calls the DLL2 every 10 counts (to fulfill 0.1s calling convention).

    Can you guys help me out?
    Last edited by DampfHans; 07-06-2010 at 05:28 AM.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,294
    Quote Originally Posted by DampfHans View Post
    So I think the best would be to set the communication interval to 0.01s to fulfill the calling convention for DLL1 and using a counter the calls the DLL2 every 10 counts (to fulfill 0.1s calling convention).
    Depends on how accurate the timing of the calls needs to be. It will also be affected by how long the functions take to run.

    Keep in mind that, unless you are using an RTOS (an operating system designed to ensure predictability of timing) there will be significant jitter in any timing. Using windows, for example, the jitter in a Sleep() call can be tens of milliseconds - and that's assuming there aren't other processes consuming significant CPU cycles.
    Right 98% of the time, and don't care about the other 3%.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    13
    Quote Originally Posted by grumpy View Post
    Depends on how accurate the timing of the calls needs to be. It will also be affected by how long the functions take to run.
    Correct, i think, the most important thing is the the 2nd dll function is called only every 10 steps.

    Directly accessing dll2 with at rate of 0.1s caused return values - switchin to 0.01s returned nothing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. NtSetSystemTime() failed
    By medp7060 in forum C++ Programming
    Replies: 11
    Last Post: 04-02-2010, 02:58 AM
  2. Using pointers
    By Big_0_72 in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 07:51 PM
  3. need help in time zone
    By Gong in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2007, 03:44 AM
  4. Help with assignment!
    By RVDFan85 in forum C++ Programming
    Replies: 12
    Last Post: 12-02-2006, 11:46 PM
  5. relating date....
    By Prakash in forum C Programming
    Replies: 3
    Last Post: 09-19-2001, 09:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21