comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to: communication between multiple tasks using protected objects - with no polling?
Date: Wed, 21 Jan 2015 21:15:46 +0100
Date: 2015-01-21T21:15:46+01:00	[thread overview]
Message-ID: <1x7jndf8up05d.1n1l3ck15y1lf.dlg@40tude.net> (raw)
In-Reply-To: 87a91c0xpq.fsf@adaheads.sparre-andersen.dk

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

  reply	other threads:[~2015-01-21 20:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 22:36 How to: communication between multiple tasks using protected objects - with no polling? Esa Riihonen
2015-01-21  0:19 ` Hubert
2015-01-21 16:53   ` Esa Riihonen
2015-01-21 23:22     ` Hubert
2015-01-22 13:24       ` Esa Riihonen
2015-01-21  0:47 ` Jeffrey Carter
2015-01-21  8:11   ` Simon Wright
2015-01-21 17:16   ` Esa Riihonen
2015-01-21 18:39     ` Jeffrey Carter
2015-01-22 13:32       ` Esa Riihonen
2015-01-21  8:28 ` Dmitry A. Kazakov
2015-01-21 17:34   ` Esa Riihonen
2015-01-21 18:56     ` Jacob Sparre Andersen
2015-01-21 20:15       ` Dmitry A. Kazakov [this message]
2015-01-22 21:52         ` G.B.
2015-01-23  8:25           ` Dmitry A. Kazakov
2015-01-21 20:02     ` Dmitry A. Kazakov
2015-01-22 13:37       ` Esa Riihonen
replies disabled

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