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.189.233 with SMTP id gl9mr12599169pbc.8.1323785038744; Tue, 13 Dec 2011 06:03:58 -0800 (PST) Path: lh20ni17925pbb.0!nntp.google.com!news1.google.com!goblin3!goblin.stu.neva.ru!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Interrupts handling in ADA Date: Tue, 13 Dec 2011 15:04:04 +0100 Organization: cbb software GmbH Message-ID: <1f0ump3yhi731$.1gh4827ra0a87.dlg@40tude.net> References: <30143086.6.1323549838421.JavaMail.geo-discussion-forums@vbbfq24> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.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-13T15:04:04+01:00 List-Id: On Tue, 13 Dec 2011 05:11:14 -0800 (PST), Ada BRL wrote: > On 11 Dic, 09:23, "Dmitry A. Kazakov" > wrote: >> 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 would have liked to use dll import to exchange data between C stuff > and Ada program instead of using two programs (C and Ada) > communicating through sockets... You can link to an import library from Ada without any problems. Which OS are you using? > I have a maximum of 5 sockets so I guess there will be no problems > onto the OS side...I hope so =). Yep. > What's the "select" you have just mentioned? E.g. under Windows: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740141%28v=vs.85%29.aspx > The software interrupts are implemented with entry / accept paradigm > (like events in C++? ). No, OS event objects and entry calls assume that the recipient is inactive and thus is ready to accept the notification. That is a non-preemptive model. Software interrupts are preemptive. An interrupt breaks the execution of the recipient. Like with exceptions there are two models of what happens after interrupt has been serviced: continuation back from the point where the task was interrupted vs. winding up the stack and aborting some stuff with continuation from a definite point. AST's are usually like former, Ada's ATC are like latter. >> 2. "Monitor": multiple socket readers do rendezvous to the main task, which >> accept the rendezvous. > > In rendez-vous paradigm, is the main task forced to wait for ALL the > socket tasks or only for a subset of them? It is an asymmetric model. The subscriber does not know the publishers. It waits for any entry call, services it, and then wait for another. > Eg: only socket #2 has received some data, can the main task execute > or does it have to wait also for the other sockets? One by one, if you need something like synchronization at the checkpoint, that would possible to implement using monitors, but it would be a bit hairy. I would use arrays of events instead. >> 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. > > In your opinion, what's the most effective and at the same time > simplest way to sort out my problem? Efficiency depends on the network stack you are using. In general, protected objects could be more efficient where context switching is expensive. This is because in some cases protected entries can be serviced without switching tasks (threads). On the architectures with many cores, where switching is relatively cheap and locking is relatively expensive, tasks rendezvous might become preferable. However, if you care about performance, you have always measure, never guess. > Simon Wright has posted an example of Protected queue and entry / > accept statements and it seems to be simple but effective as well. See above, speculations about efficiency are dangerous. I would refrain copying socket data, but if it works for you, why not? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de