comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Interrupts handling in ADA
Date: Sun, 11 Dec 2011 10:23:52 +0100
Date: 2011-12-11T10:23:52+01:00	[thread overview]
Message-ID: <p0zhmvtwkae5.1elap57996uf8$.dlg@40tude.net> (raw)
In-Reply-To: 30143086.6.1323549838421.JavaMail.geo-discussion-forums@vbbfq24

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



  parent reply	other threads:[~2011-12-11  9:23 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 [this message]
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
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