Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MsgWaitFor...()-compatible condvar implementation that can be shared across processes

274 views
Skip to first unread message

Jason S

unread,
Apr 17, 2008, 10:32:21 AM4/17/08
to
I have a stumper... I need to implement a condition variable in win32
on Win2K and WinXP that is compatible with MsgWaitForMultipleObjects
so that I can use it w/ COM STA apartments that require message loops
to be serviced (and also with COM MTA apartments... otherwise I would
just use a window broadcast message).

So far I'm stuck. I was going to use manual-reset events + PulseEvent
but then saw the warnings about PulseEvent + kernel APC causing the
event to be missed.

I looked a little bit at pthreads-w32 but realized I can't use them w/
MsgWait...() and anyway it looks like pthreads-w32 doesn't support
inter-process condvars.

Is there a freely-available method to do this, that is posted on the
'net somewhere? (or am I screwed?)

Also, is there a way for me to be sure I can test that it works
properly, by queueing a long-duration APC somehow after a thread calls
MsgWait...() but before the condvar has been signaled? I know next to
nothing about APCs.

Chris Thomasson

unread,
Apr 17, 2008, 11:29:00 AM4/17/08
to
"Jason S" <jms...@gmail.com> wrote in message
news:1b64b182-e7fc-4ecd...@l64g2000hse.googlegroups.com...

>I have a stumper... I need to implement a condition variable in win32
> on Win2K and WinXP that is compatible with MsgWaitForMultipleObjects
> so that I can use it w/ COM STA apartments that require message loops
> to be serviced (and also with COM MTA apartments... otherwise I would
> just use a window broadcast message).
>
> So far I'm stuck. I was going to use manual-reset events + PulseEvent
> but then saw the warnings about PulseEvent + kernel APC causing the
> event to be missed.
>
> I looked a little bit at pthreads-w32 but realized I can't use them w/
> MsgWait...() and anyway it looks like pthreads-w32 doesn't support
> inter-process condvars.
[...]

You can indeed convert Alex Terekhovs algorithm in pthread-win32 to a
shared-memory version.

Jason S

unread,
Apr 17, 2008, 1:02:47 PM4/17/08
to
On Apr 17, 11:29 am, "Chris Thomasson" <cris...@comcast.net> wrote:
> > I looked a little bit at pthreads-w32 but realized I can't use them w/
> > MsgWait...() and anyway it looks like pthreads-w32 doesn't support
> > inter-process condvars.
>
> [...]
>
> You can indeed convert Alex Terekhovs algorithm in pthread-win32 to a
> shared-memory version.

you mean the "8a" algorithm listed in comp.programming threads (http://
groups.google.com/group/comp.programming.threads/browse_thread/thread/
1692bdec8040ba40?hl=en&tvc=2) in README.CV / pthread_cond_wait.c?

(thanks... searching for Terekhov algorithm in google just seems to
lead to other references to Terekhov's algorithm, took me a while to
find it)

Chris Thomasson

unread,
Apr 18, 2008, 8:37:52 PM4/18/08
to
On Thu, 17 Apr 2008 10:02:47 -0700, Jason S wrote:

> On Apr 17, 11:29 am, "Chris Thomasson" <cris...@comcast.net> wrote:
>> > I looked a little bit at pthreads-w32 but realized I can't use them w/
>> > MsgWait...() and anyway it looks like pthreads-w32 doesn't support
>> > inter-process condvars.
>>
>> [...]
>>
>> You can indeed convert Alex Terekhovs algorithm in pthread-win32 to a
>> shared-memory version.
>
> you mean the "8a" algorithm listed in comp.programming threads (http://
> groups.google.com/group/comp.programming.threads/browse_thread/thread/
> 1692bdec8040ba40?hl=en&tvc=2) in README.CV / pthread_cond_wait.c?

Yup.


> (thanks... searching for Terekhov algorithm in google just seems to
> lead to other references to Terekhov's algorithm, took me a while to
> find it)

Sorry for not providing a link.

0 new messages