Article View: borland.public.cppbuilder.nativeapi
Article #11034Re: synchronizing access to named mutexes
From: Remy Lebeau (TeamB)
Date: Sat, 28 Feb 2004 22:37
Date: Sat, 28 Feb 2004 22:37
33 lines
2480 bytes
2480 bytes
"Dennis Jones" <djones@nospam.com> wrote in message news:4040bd56$1@newsgroups.borland.com... > And now that I think > about it, I might have been able to do the same thing with one of my > mutexes too. After all, I was able to wait on the event handle before > the EXE had opened its own handle to it -- so why not a mutex? I do not recommend a mutex. The DLL cannot wait for the EXE to signal a mutex as easily as it can an event. As soon as the DLL creates the mutex, it would usually end up obtaining ownership of the mutex before the application could open it. Thus the EXE would be waiting on the DLL, not the other way around. An event is better suited for this task instead. > Given that the event worked, and that it seems likely that a mutex > would work the same way Not exactly. > it seems odd to me that one could not open a mutex, set it to > the signaled state, and then have another process open a handle > to that same mutex and have a wait succeed. A mutex is signaled when it is unowned. The first process to call WaitForSingleObject() will own the mutex and set it back to unsignaled so other processes wait for it. If the DLL creates it first, changes are the DLL will become the first owner, not the EXE. But you wanted the DLL to wait on the EXE, not the other way around, so a mutex does not work very well for that. Gambit
Technical Details
Message-ID:
<40411615$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<403ea9c9$1@newsgroups.borland.com> <dhnu305gp72fdko73lfr2ckr0ps4l7ltf5@4ax.com> <403f6f4c$1@newsgroups.borland.com> <403f8f1c@newsgroups.borland.com> <4040bd56$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,147e3de49808f5a X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-28 14:39:37 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <403ea9c9$1@newsgroups.borland.com> <dhnu305gp72fdko73lfr2ckr0ps4l7ltf5@4ax.com> <403f6f4c$1@newsgroups.borland.com> <403f8f1c@newsgroups.borland.com> <4040bd56$1@newsgroups.borland.com> Subject: Re: synchronizing access to named mutexes Date: Sat, 28 Feb 2004 14:37:02 -0800 Lines: 35 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <40411615$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1078007317 67.22.138.253 (28 Feb 2004 14:28:37 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail