From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,371144ace2969d7e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!news-xxxfer.readnews.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: C++ primer on multithreading Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Wed, 20 Apr 2011 13:32:45 +0200 Message-ID: <1j105rxzcl721.1jcmdtbk8zx7j.dlg@40tude.net> NNTP-Posting-Date: 20 Apr 2011 13:32:42 CEST NNTP-Posting-Host: 55931013.newsspool3.arcor-online.net X-Trace: DXC=g7]5Wg5J80\E47KDAk81NWMcF=Q^Z^V3X4Fo<]lROoRQ8kF 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