LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Semaphore Applications

Does someone know where I could find some Applications solved with Semaphores, Events, Mutex, etc.? I mean examples like the Mailbox mechanism.

 

Thanks a lot.

0 Kudos
Message 1 of 5
(6,138 Views)

To syncronize threads you can find examples using the Cmt functions in the threading and async timer CVI sample code.

 

For syncronizing two indpendent applications, things get a lot tougher, especially if one is in CVI and the other is say C++,  the CVI Windows SDK docs has some examples of using Mutex Objects.

 

In fact I'm researching this issue now, a named mutex object should meet my needs, can't say anything about yours.

 

I've done it in Linux using semop() & semctl() as reasonably well documented in: Beginning Linux Programming, Stones & Matthew, Wrox Press 1999; page 462+  but none of this seems to directly apply to Windows as the POSIX semop functions do not appear to be part of the Windows SDK.  There may be some POSIX Windows addons I'm not aware of.

 

--wally.

 

0 Kudos
Message 2 of 5
(6,113 Views)

The windows SDK has some examples using those synchronization mechanism, but nothing really complicated. there are also a lot of books discussing the problems: "object-oriented multithreading in C++" for example...

 

Anyway, there is a lot of ways to use semaphores, events and mutexes. what are you looking for exactly ? are you trying to understand the mechanisms ? do you have a problem that you think may be solved by those ? are you just curious about that ?

 

0 Kudos
Message 3 of 5
(6,094 Views)

There may be some POSIX Windows addons I'm not aware of.

 


I found some on Microsoft's Technet sight, but they appear to only be for windows server versions, in any event, I've got it working using a memory mapped file to pass data between the two applications using a named mutex to serialize access between the apps so read or write operations are always complete and data intact.

 

--wally.

 

Message Edited by wally_666 on 06-25-2009 07:28 AM
0 Kudos
Message 4 of 5
(6,086 Views)

We've done a lot of this in CVI.

 

Win32 mutex, critical section, semaphore, event use from CVI are straightforward in my opinion.   Of course, multi-threaded applications can be a nightmare if you don't know what you're doing.

 

Mailbox I/O, pipes, memory mapped files (shared memory) are more complicated.

 

I prefer to use the Win32 mechanisms directly via calls to the Win32 API as documented in the Win32 SDK, as opposed to using the NI facilities (which are built on the same underlying OS mechanisms anyway).  The Win32 SDK documentation can be a bit obtuse at times - they sometimes offer dogmatic statements in the descriptions that turn out to actually be specific to certain situations that could be different for your application.

 

I used several text books to supplement the SDK documentation.  One was called "Windows System Programming" ISBN 978-0321256195 by Johnson Hart and was very good.  A person named Jeffrey Ricther has written good Windows books.    This book by Beveridge and Weiner ISBN 978-0201442342  is aging but still very good.

 

 

Menchar

 

 

 

 

 

0 Kudos
Message 5 of 5
(6,069 Views)