comp.lang.ada
 help / color / mirror / Atom feed
From: Ada BRL <ada.brl.2011@gmail.com>
Subject: Re: Interrupts handling in ADA
Date: Tue, 13 Dec 2011 06:08:51 -0800 (PST)
Date: 2011-12-13T06:08:51-08:00	[thread overview]
Message-ID: <410af1b2-f050-43ed-99ef-1d619b3b8325@j9g2000vby.googlegroups.com> (raw)
In-Reply-To: 4ee49c6a$0$6562$9b4e6d93@newsspool4.arcor-online.net


Sorry, I replied you privately before, instead of the group.


On 11 Dic, 12:04, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
> 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?

I have several tasks:

Ada side:
3 sockets communicating with C/C++ sockets plus main task,

C/C++ side:
lots of threads, 3 of these are sockets communicating with Ada
sockets.

>
> 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.

As I asked in another post, what's the select statement? :-)

>
> (That'shttp://en.wikibooks.org/wiki/Ada_Programming/Tasking#Rendezvous
> on the page mentioned by Niklas Holsti. There is alsohttp://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

Using Mailbox, is the socket task  - that has received the data and
called the accept event - blocked while the main task runs?

Eg:
Socket1.data_arrived;

Inside main task: accept data_arrived;

Is at this point Socket1 blocked or not?

Another question:

Inside the main task, do I have to specify different entries for all
the sockets like:
E.g.:
entry data_arrived_1; -- for socket #1
entry data_arrived_2; -- for socket #2
entry data_arrived_3; -- for socket #3

and then
accept data_arrived_1;
accept data_arrived_2; etc...

or I have to specify just one entry and I call it from different
socket tasks?
E.g.:
socket1.data_arrived;
socket2.data_arrived; etc...

I guess it's the second option because in the first case for example
the accept data_arrived_2 cannot be executed until data_arrived_1 is
called.

Thanks!





  reply	other threads:[~2011-12-13 14:08 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
2011-12-13 14:08   ` Ada BRL [this message]
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