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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bdf72b2364b0da13 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.212.232 with SMTP id nn8mr12777126pbc.1.1323785339046; Tue, 13 Dec 2011 06:08:59 -0800 (PST) Path: lh20ni17939pbb.0!nntp.google.com!news1.google.com!postnews.google.com!j9g2000vby.googlegroups.com!not-for-mail From: Ada BRL Newsgroups: comp.lang.ada Subject: Re: Interrupts handling in ADA Date: Tue, 13 Dec 2011 06:08:51 -0800 (PST) Organization: http://groups.google.com Message-ID: <410af1b2-f050-43ed-99ef-1d619b3b8325@j9g2000vby.googlegroups.com> References: <30143086.6.1323549838421.JavaMail.geo-discussion-forums@vbbfq24> <4ee49c6a$0$6562$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Host: 164.11.203.58 Mime-Version: 1.0 X-Trace: posting.google.com 1323785338 6354 127.0.0.1 (13 Dec 2011 14:08:58 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 13 Dec 2011 14:08:58 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j9g2000vby.googlegroups.com; posting-host=164.11.203.58; posting-account=yig7mwoAAAAAcduNbH7Dpal1sjCSAijA User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUARELSCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-12-13T06:08:51-08:00 List-Id: Sorry, I replied you privately before, instead of the group. On 11 Dic, 12:04, Georg Bauhaus 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 carryi= ng 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 networ= k sockets). > > [I decided to use the sockets instead of dll/lib import because this ap= proach hasn't worked... =3D( ] > > 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 > > =A0 =A0 ... > =A0 =A0 B.Data_Available; =A0-- =A0A notifies B > =A0 =A0 ... > > 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 > > =A0 =A0 ... > =A0 =A0 B.Data_Available (Data_To_Be_Sent); > =A0 =A0 ... > > 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. =A0The mailbox can be a protected object > (language defined term, roughly clever type for shared variables with mut= ex > and conditional waiting), or another dedicated task object. The model > in either case =A0is: > > =A0 =A0 -- body of A: > =A0 =A0 Mailbox.Add_Data (Data_for_B); =A0-- make data available > =A0 =A0 B.Data_Available; =A0 -- notify B of data available, as before > =A0 =A0 ... > > =A0 =A0 -- body of B: > =A0 =A0 accept Data_Available; =A0-- be notified of data available in mai= lbox > =A0 =A0 Mailbox.Get_Data (Storage =3D> Room_for_Data); > =A0 =A0 =A0 =A0-- 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. =A0For 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!