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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to: communication between multiple tasks using protected objects - with no polling? Date: Wed, 21 Jan 2015 21:15:46 +0100 Organization: cbb software GmbH Message-ID: <1x7jndf8up05d.1n1l3ck15y1lf.dlg@40tude.net> References: <32208488-3a04-4d2a-8c64-840502dcf96d@googlegroups.com> <87a91c0xpq.fsf@adaheads.sparre-andersen.dk> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 0MSBVPcE8EdvhPFyEbPM4g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:24677 Date: 2015-01-21T21:15:46+01:00 List-Id: On Wed, 21 Jan 2015 19:56:17 +0100, Jacob Sparre Andersen wrote: > Esa Riihonen wrote: > >> So - in my mind I have a small number of students each with a separete >> blackboard. And instead of my teacher walking around checking whether >> the answer of any of the sudents is ready - I wan't to let the teacher >> doze in his/her chair and only be woken up when any of the students >> have their answer ready. And after the student briefly nudges the >> teacher he/she must be free to immediately continue with his/her other >> exams. >> >> I guess I just don't know how this 'blackboard' model should be >> implemented? > > To me it sounds like a single protected object for storing the state of > all the workers (students) makes most sense. The workers can push in > their most recent state through a (common) protected procedure. The > master (teacher) blocks on a protected entry until at least one worker > has updated its state. Right, though this works only with a single subscriber (the teacher). Usually there are more than one and you could not keep the reader's state in the object anymore, at least when the number of subscribers is not statically known. You could pass the reader's state to the entry as a parameter and use tricks to circumvent the rule that parameters may not appear in the barriers, but that would be more complicated than moving the storage out of the PO. In general I try to avoid maintaining complex containers from protected actions. Yes, this might be probably non-blocking, but still, I find it a bad idea to allocate/copy/initialize much there. E.g. storing should use a mutex instead. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de