comp.lang.ada
 help / color / mirror / Atom feed
From: Esa Riihonen <esa.riihonen.er@gmail.com>
Subject: Re: How to: communication between multiple tasks using protected objects - with no polling?
Date: Wed, 21 Jan 2015 08:53:46 -0800 (PST)
Date: 2015-01-21T08:53:46-08:00	[thread overview]
Message-ID: <e4dd31bd-1248-4aac-88ad-748cd0c3e94d@googlegroups.com> (raw)
In-Reply-To: <ygCvw.930507$Hb3.567654@fx03.iad>

keskiviikko 21. tammikuuta 2015 2.19.43 UTC+2 Hubert kirjoitti:

... snip ...

> So my solution was to have one protected object that serves as a form of 
> event buffer.
> 
> Any section of my code that needs to communicate with the task, writes 
> an event into the PO. The task then waits for an event in the PO. the PO 
> provides these events through an entry with a  barrier that is something 
> like "WHEN LENGTH( Event_Queue) > 0".

The thing is that in this special case I have in mind my 'writers' are just reporting their status once in a while and have more important things to do - so I don't want them blocked. If I have just one PO for the 'reader' then the 'writers' might block each other and be unnecessry blocked while the 'reader' is going through the messages of the other 'writers'. Thus I tried to build the system with one separete PO for each writer task. 
 
I guess that in practice the associated blocking delays are not a concern in this case. But as I'm using this as an excercise for Ada I'm also concerned about this 'in principle' ;)

> You can then also use a timed select statement like so:
> 
> SELECT
>    Wait_For_Event( PO );
> OR
>    Delay 1.0;
> END SELECT
> 
> which will time out after 1 second and allow your task to do something 
> else before entering the select statement again in a loop. For instance 
> you could check for a task entry that commands your task to halt and 
> exit, if you want to delete the task or shut down the program

That is a good point - I probably will end up implementing the logic along these lines. 

Thanks.

... snip ...


  reply	other threads:[~2015-01-21 16:53 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 [this message]
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
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