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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.42.68.4 with SMTP id v4mr27705121ici.16.1421859226729; Wed, 21 Jan 2015 08:53:46 -0800 (PST) X-Received: by 10.140.39.39 with SMTP id u36mr22989qgu.17.1421859226687; Wed, 21 Jan 2015 08:53:46 -0800 (PST) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!h15no1367343igd.0!news-out.google.com!l7ni0qai.0!nntp.google.com!bm13no2083621qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 21 Jan 2015 08:53:46 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=80.223.109.117; posting-account=xMk30AoAAACEWgBjdZfjW9cEqRCtnf-j NNTP-Posting-Host: 80.223.109.117 References: <32208488-3a04-4d2a-8c64-840502dcf96d@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: How to: communication between multiple tasks using protected objects - with no polling? From: Esa Riihonen Injection-Date: Wed, 21 Jan 2015 16:53:46 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:191975 Date: 2015-01-21T08:53:46-08:00 List-Id: 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= =20 > event buffer. >=20 > Any section of my code that needs to communicate with the task, writes=20 > an event into the PO. The task then waits for an event in the PO. the PO= =20 > provides these events through an entry with a barrier that is something= =20 > 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 d= o - so I don't want them blocked. If I have just one PO for the 'reader' th= en the 'writers' might block each other and be unnecessry blocked while the= 'reader' is going through the messages of the other 'writers'. Thus I trie= d to build the system with one separete PO for each writer task.=20 =20 I guess that in practice the associated blocking delays are not a concern i= n this case. But as I'm using this as an excercise for Ada I'm also concern= ed about this 'in principle' ;) > You can then also use a timed select statement like so: >=20 > SELECT > Wait_For_Event( PO ); > OR > Delay 1.0; > END SELECT >=20 > which will time out after 1 second and allow your task to do something=20 > else before entering the select statement again in a loop. For instance= =20 > you could check for a task entry that commands your task to halt and=20 > 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.=20 Thanks. ... snip ...