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.182.241.2 with SMTP id we2mr4236464obc.38.1413303915196; Tue, 14 Oct 2014 09:25:15 -0700 (PDT) X-Received: by 10.140.84.137 with SMTP id l9mr47675qgd.12.1413303915166; Tue, 14 Oct 2014 09:25:15 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!uq10no10626162igb.0!news-out.google.com!i10ni87qaf.0!nntp.google.com!dc16no2817724qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 14 Oct 2014 09:25:14 -0700 (PDT) In-Reply-To: <52c27795-4b83-4409-af5f-fb24299845f3@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=158.110.27.77; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 NNTP-Posting-Host: 158.110.27.77 References: <41154c4b-6158-4701-ab25-85afa3b24ed2@googlegroups.com> <55ca779f-022c-4712-84df-55672e5ccb1e@googlegroups.com> <3802f993-6614-4a64-93c9-6072bc72959b@googlegroups.com> <1244b718-fa93-4ded-a525-5051c78b0a7b@googlegroups.com> <52c27795-4b83-4409-af5f-fb24299845f3@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3cca54b6-7144-4f97-ac2f-1de7cc119e28@googlegroups.com> Subject: Re: passing messages between the tasks From: mockturtle Injection-Date: Tue, 14 Oct 2014 16:25:15 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:22464 Date: 2014-10-14T09:25:14-07:00 List-Id: On Tuesday, October 14, 2014 5:30:58 PM UTC+2, comp...@gmail.com wrote: > how would you be able to recal these values... >=20 > say i want to print b of task 1 > and I of task 2 The first solution that comes to my mind (and maybe the only one) is to pro= vide your task with two entries: one to read the value of B and the other t= o read the value of I. Those entries would have a OUT parameter where the = task will write the desired values. The accept statement would look someth= ing like=20 accept Get_I(Result: out Integer) do Result :=3D I; end Get_I; and you could use something like Lamps(2).Get_I(V); put_line(Integer'Image(V)); Of course, the accept statement causes a "synchronization" between the "mai= n task" and task Lamps(2), so that when the execution reaches "Lamps(2).Get= _I(V)" the main task will stop until Lamps(2) reaches the "accept" statemen= t. If this synchronized behavior is undesired (you want to query I and B at an= y time, "asynchronously") I guess that the only solution is using a protect= ed object. In this case things get a bit more complicated, but a possible = solution could be this (disclaimer: I did not check the code) 1. You declare a protected type (call it "Protected_Buffer") with proced= ures like "Set_I", "Get_I", ... In this case Get_I and Get_B can be functi= ons 2. When the lamp task starts it allocates a Protected_Buffer with new=20 3. The lamp task updates the values of B and I by using the methods Set_= I and Set_B of the protected object 4. In order to allow the "main task" to access the values stored in the = protected object, the lamp task needs to "export" the access to the allocat= ed buffer. This can be done by providing the task with an entry similar to type Buffer_Access is access to Protected_Buffer; entry Get_Buffer_Access(acc : out Buffer_Access); 5. The main task first gets the access to the protected buffer by callin= g something like Lamps(2).Get_Buffer_Access(acc); then it can print the value of, say, I by calling Put_Line(Integer'Image(acc.Get_I)); A problem with this solution is that the main task could write the values o= f I and B by calling, say, acc.Set_I(42). If this is a problem, I think yo= u can "wrap" the protected object inside a tagged type, make "Get" function= s "public" while "Set" procedures "private." =20 Lots of details left to the reader... :-) Riccardo