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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA 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-7-bit Received: by 10.68.189.233 with SMTP id gl9mr6442159pbc.8.1323605099230; Sun, 11 Dec 2011 04:04:59 -0800 (PST) Path: lh20ni10115pbb.0!nntp.google.com!news1.google.com!goblin3!goblin1!goblin2!goblin.stu.neva.ru!feeder2.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sun, 11 Dec 2011 13:04:58 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Interrupts handling in ADA References: <30143086.6.1323549838421.JavaMail.geo-discussion-forums@vbbfq24> In-Reply-To: <30143086.6.1323549838421.JavaMail.geo-discussion-forums@vbbfq24> Message-ID: <4ee49c6a$0$6562$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 11 Dec 2011 13:04:58 CET NNTP-Posting-Host: f826d42d.newsspool4.arcor-online.net X-Trace: DXC=mQbmh]40jYSV0Pe9PRnbJ\4IUK_dSPCY\c7>ejVXd519PWWi5g]]FD72ECEI3^ X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-12-11T13:04:58+01:00 List-Id: 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