CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    Timisoara, Romania
    Posts
    460

    How to syncronize 2 dll's

    Hi,
    I have 2 dll's in an application. One process, 2 different threads. The 2 dll's are some kind of data sources and they need to start a data cycle at same time. The 3rd dll is a vizualization which has to show up the data. How can I make the 2 data sources start transmiting data at the same time. I tried using 2 mutexes but I end up blocking the entire procees. Can you please guide me to some articles or documentation that could help?
    Thank you!
    You liked it? Please show your gratitude and rate it!

    There is no 'patch' for stupidity.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: How to syncronize 2 dll's

    On single cores, there is no "same time". Even though you have multiple threads, they run at different time slots. So when you say "same time" that means most likely "about the same time".

    Why don't you explained how you tried to synchronize the two, maybe we can figure what was wrong.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Oct 2003
    Location
    Timisoara, Romania
    Posts
    460

    Re: How to syncronize 2 dll's

    so here is what I've done:
    1. In Source1 I start Mutex1 and after that I wait for Mutex2
    2. In Source2 I wait for Mutex1 and when I got it I start Mutex2.

    Here is data source 1:
    Code:
    m_h_ghMutex1 = CreateMutex(NULL, FALSE, TEXT("SignalGenerator1"));
    DWORD dwMutexResult;
    	do {
    		m_h_ghMutex2 = OpenMutex(MUTEX_ALL_ACCESS, FALSE, TEXT("SignalGenerator2")); 
    			
    		dwMutexResult = WaitForSingleObject(m_h_ghMutex2, 1000L);
    	}
    	while (dwMutexResult != WAIT_OBJECT_0);
    //----start sending data----
    In data source 2:
    Code:
    DWORD dwMutexResult;
    	do {
    		m_h_ghMutex1 = OpenMutex(MUTEX_ALL_ACCESS, FALSE, TEXT("SignalGenerator1")); 
    		dwMutexResult = WaitForSingleObject(m_h_ghMutex1, 1000L);
    	} while (dwMutexResult != WAIT_OBJECT_0);
    	m_h_ghMutex2 = CreateMutex(NULL, FALSE, TEXT("SignalGenerator2"));
    //---start sending data---
    L.E. I know there is no such thing like "same time" but something unsesizable by human eye would be good enough for me
    Last edited by vma; March 10th, 2009 at 08:10 AM.
    You liked it? Please show your gratitude and rate it!

    There is no 'patch' for stupidity.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured