comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Interrupts handling in ADA
Date: Sun, 11 Dec 2011 13:04:58 +0100
Date: 2011-12-11T13:04:58+01:00	[thread overview]
Message-ID: <4ee49c6a$0$6562$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <30143086.6.1323549838421.JavaMail.geo-discussion-forums@vbbfq24>

On 10.12.11 21:43, Ada @ BRL wrote:
> Hello,
> I'm an Erasmus student at the University of Bristol - UK and I'm carrying out the work for my master thesis in Computer Engineering.
>
> I'm programming a multithreading application in C / C++ and ADA.
> The latter is a completely new language for me...
>
> The environment of ADA applcation is:
> I have 4 tasks that execute at the same time:
> one is the main task,
> the other three execute a "read" from network (socket) function inside their bodies (on the other side there's the C/C++ application with 3 network sockets).
> [I decided to use the sockets instead of dll/lib import because this approach hasn't worked... =( ]

Just to make sure: Do you have 4 Ada tasks that should
communicate, or do you have an Ada program and 3 programs
or pthread style functions written in C or C++ that should
communicate with the Ada program?

In the first case, simply look for "entry", "select", and "accept",
These means of inter-task communications have been built into Ada
since day 1.

(That's
http://en.wikibooks.org/wiki/Ada_Programming/Tasking#Rendezvous
on the page mentioned by Niklas Holsti. There is also
http://www.adaic.org/learn/materials/ )

Say I have two task objects A and B, and B should accept calls from other
tasks at an entry named "Data_Available". The notification is written
in the body the calling task, A in this case. It could look like

    ...
    B.Data_Available;  --  A notifies B
    ...

Done. That's all. If A also wishes to send data directly, then
B would accept them simply in a parameter. Then, "Data_Available"
would have been declared with a parameter instead of without one
as in the case above.
The notification, which then includes data to be sent, could look like

    ...
    B.Data_Available (Data_To_Be_Sent);
    ...

It is also possible to combine the first, simple notification (without
data) with employing a third object, a mailbox style object, as outlined
in other answers in this thread.  The mailbox can be a protected object
(language defined term, roughly clever type for shared variables with mutex
and conditional waiting), or another dedicated task object. The model
in either case  is:

    -- body of A:
    Mailbox.Add_Data (Data_for_B);  -- make data available
    B.Data_Available;   -- notify B of data available, as before
    ...

    -- body of B:
    accept Data_Available;  -- be notified of data available in mailbox
    Mailbox.Get_Data (Storage => Room_for_Data);
       -- load from mailbox and store into a variable local to B

Or you could have B wait at the mailbox until A makes data
available in the mailbox. The tasks would not have to communicate
directly, then.  For this to work, the Mailbox object will
a procedure for tasks that wish to add data to the mailbox, and
an entry for tasks that wish to get data out of the mailbox,
"E" say. The entry is guarded by a barrier. The barrier
will get lifted as soon as a task such as a A has supplied data
to the box. The effect is then that a task like B, having waited
in the queue of entry "E", will be "notified" of the presence
of data and continues, i.e., loads data from the mailbox.



- HTH Georg



  parent reply	other threads:[~2011-12-11 12:04 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-10 20:43 Interrupts handling in ADA Ada @ BRL
2011-12-10 21:13 ` Vinzent Hoefler
2011-12-10 22:09 ` Niklas Holsti
2011-12-10 22:27 ` Simon Wright
2011-12-11 20:21   ` Martin Dowie
2011-12-13 13:51     ` Ada BRL
2011-12-13 23:18       ` Martin Dowie
2011-12-13 14:11     ` Niklas Holsti
2011-12-13 14:54       ` Simon Wright
2011-12-13 15:06         ` Ada BRL
2011-12-13 21:49           ` Niklas Holsti
2011-12-13 23:18       ` Martin Dowie
2011-12-13 12:47   ` Ada BRL
2011-12-13 15:07     ` Simon Wright
2011-12-13 15:23       ` Ada BRL
2011-12-13 18:14         ` Simon Wright
2011-12-13 18:56           ` Ada BRL
2011-12-13 19:56           ` Bill Findlay
2011-12-13 22:15         ` Niklas Holsti
2011-12-13 15:34       ` Simon Wright
2011-12-13 17:55         ` Ada BRL
2011-12-13 18:18           ` Dmitry A. Kazakov
2011-12-13 19:01             ` Ada BRL
2011-12-13 19:58               ` Dmitry A. Kazakov
2011-12-13 18:24           ` Simon Wright
2011-12-11  0:15 ` Jeffrey Carter
2011-12-13 12:53   ` Ada BRL
2011-12-11  9:23 ` Dmitry A. Kazakov
2011-12-13 13:11   ` Ada BRL
2011-12-13 14:04     ` Dmitry A. Kazakov
2011-12-13 14:51       ` Ada BRL
2011-12-13 15:02         ` Ada BRL
2011-12-13 15:39         ` Dmitry A. Kazakov
2011-12-13 18:51           ` Ada BRL
2011-12-13 19:51             ` Dmitry A. Kazakov
2011-12-13 23:32             ` georg bauhaus
2011-12-11 12:04 ` Georg Bauhaus [this message]
2011-12-13 14:08   ` Ada BRL
2011-12-12  3:19 ` anon
2011-12-12  9:12   ` Niklas Holsti
2011-12-13 13:36     ` Ada BRL
2011-12-12 15:23   ` björn lundin
2011-12-13 13:38     ` Ada BRL
2011-12-13 13:56       ` Ludovic Brenta
2011-12-13 14:10         ` Ada BRL
2011-12-13 13:31   ` Ada BRL
replies disabled

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