comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: C++ primer on multithreading
Date: Wed, 20 Apr 2011 13:32:45 +0200
Date: 2011-04-20T13:32:42+02:00	[thread overview]
Message-ID: <1j105rxzcl721.1jcmdtbk8zx7j.dlg@40tude.net> (raw)
In-Reply-To: iomdg2$h3t$1@dont-email.me

On Wed, 20 Apr 2011 12:45:22 +0200, Alex R. Mosteo wrote:

> I know there are some proficient C++ people here. Hope you can help me.
> 
> I need to do some multi-threading stuff, in the sense that I will need the 
> equivalent of a protected object with some conditional blocking entries.

Equivalent of an entry is an event+queue combination. Threads are queued to
the entry. Upon an evaluation of the barrier the first thread from the
queue gets its event signalled and then removed from the queue.
Alternatively to the events one can suspend/resume caller's thread.

Implementation of Ada's entries is quite a challenge in C++, and this
technique is largely unknown to C++ people. Usually they just hang a mutex
on the procedures of some object. This is roughly an equivalent of Ada's
protected procedure (not entry). An entry cannot be emulated this way
without busy waiting or else periodical polling. Sometimes sets of mutexes
are used with single object to avoid busy waiting, but this is a very
dangerous technique vulnerable to deadlocking.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2011-04-20 11:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-20 10:45 C++ primer on multithreading Alex R. Mosteo
2011-04-20 11:23 ` Peter C. Chapin
2011-04-20 13:06   ` Alex R. Mosteo
2011-04-20 11:32 ` Dmitry A. Kazakov [this message]
2011-04-20 12:00 ` Maciej Sobczak
2011-04-20 13:04   ` Alex R. Mosteo
2011-04-20 14:34     ` Georg Bauhaus
2011-04-20 20:44     ` Maciej Sobczak
2011-04-21  8:50       ` Alex R. Mosteo
2011-04-21  6:58     ` Dmitry A. Kazakov
2011-04-21 21:03       ` Maciej Sobczak
2011-04-22  8:38         ` Dmitry A. Kazakov
2011-04-22 21:45           ` Maciej Sobczak
2011-04-23  6:51             ` Dmitry A. Kazakov
2011-04-23 21:35               ` Maciej Sobczak
2011-04-24  7:42                 ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox