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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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.190.2 with SMTP id gm2mr6317471pbc.4.1323595434027; Sun, 11 Dec 2011 01:23:54 -0800 (PST) Path: lh20ni9707pbb.0!nntp.google.com!news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news-transit.tcx.org.uk!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Interrupts handling in ADA Date: Sun, 11 Dec 2011 10:23:52 +0100 Organization: cbb software GmbH Message-ID: References: <30143086.6.1323549838421.JavaMail.geo-discussion-forums@vbbfq24> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: ObpUFW8LdmqnZd88FezSYQ.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-12-11T10:23:52+01:00 List-Id: On Sat, 10 Dec 2011 12:43:58 -0800 (PST), Ada @ BRL wrote: > 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... =( ] What dll import has to do with sockets, except that sockets usually are provided by a library? > I want that when new data is available on one or more socket threads, this > / these threads somehow notify the main thread that data is arrived and > then safely send the data to it. If you have many sockets, you should probably use select on them rather than blocking calls from many tasks. The maximal number of tasks supported by the OS is usually much lower than the maximal number of sockets. > I've thought to use the interrupts... Interrupt in Ada is meant more like "hardware interrupt." It is possible but unlikely that your network stack generates such interrupts or that you could have an access to them under the OS you are running. Software interrupt, also called asynchronous system trap (AST) is a different thing. What you had in mind is probably a software interrupt. The corresponding Ada mechanism is "Asynchronous Transfer of Control" (ATC). But there are much better ways. > because I haven't found any > references about the use of "events" in ADA. Events are low-level synchronization objects easily implemented using Ada protected objects, e.g.: http://www.dmitry-kazakov.de/ada/components.htm#Events Events are rarely used in Ada, because for inter task communication you have higher-level means. > I've thought to attach three different handler of interrupts into the main > task and then to generate the interrupt from the socket task with There are many ways to implement things like this: 1. One task + socket select 2. "Monitor": multiple socket readers do rendezvous to the main task, which accept the rendezvous. 3. "Queue": socket readers enqueue some data (the queue is implemented using a protected object). Other tasks (there could be many) dequeue data and do something meaningful with them. There are many kinds of queues for different purposes and of different behavior. 4. Single rank co-workers. Each socket reader processes data by themselves. In order to interlock processing there is a semaphore/mutex (implemented by a protected object), which is seized when processing starts and released afterwards. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de