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: a07f3367d7,a4db0fc323f0b09e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.belwue.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Barrier re-evaluation issue with GNAT 4.3.2 Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4ABCF87D.2090103@shaw.ca> Date: Fri, 25 Sep 2009 20:42:21 +0200 Message-ID: <1m2k0pew7wla9$.1bml843g8z0in$.dlg@40tude.net> NNTP-Posting-Date: 25 Sep 2009 20:42:21 CEST NNTP-Posting-Host: a7576631.newsspool2.arcor-online.net X-Trace: DXC=\Kj:Cgn:;CM2jYf>V4L0gLA9EHlD;3YcB4Fo<]lROoRA^YC2XCjHcbI`d7CP3Joi5KDNcfSJ;bb[EIRnRBaCd On Fri, 25 Sep 2009 11:06:05 -0600, Brad Moore wrote: > Dmitry A. Kazakov wrote: >> You must do it per a monitor task anyway. Your design is not scalable, and >> the code is not conformant to Ada, because you are using potentially >> blocking Put_Line within a protected action (in Call_Police). >> >> When an alarm is triggered, that happens at the context of a protected >> action. The protected action is quite limited to what you could do there. >> That is only non-blocking and *very* short stuff. This means that you won't >> be able to "call police" from there. You could set some flags, but you >> could not initiate any "non-instant" action otherwise than by releasing a >> task. Non-instant actions are for tasks. You need a task. If the key input >> task gets blocked beyond reach of asynchronous transfer of control, which >> is your case, because Ada does not require Text_IO abortable (yet >> misleadingly provides an example of in RM (:-)), anyway, that means, you >> inescapably need a second task. > > A real implementation of Call_Police would hopefully have more effect > then just printing a message to a console. Yes, Text_IO.Put_Line is > potentially blocking and clouds the example, thanks for catching that. > Conceivably though, it may be possible to use some other console output > that is non-blocking if Call_Police really does need to log something to > a console. Also, Call_Police does not necessarily need to involve a > task. For example, it may simply raise a signal on some hardware device > that calls 911, or turns on a siren, or flashing lights or whatever. This would mean that the hardware device encapsulated that task (e.g. HDD controller). I don't think this could be considered a realistic scenario. Hardware I/O on most platforms is too slow to be performed from a protected action. If you have an OS, it is 10-100 times slower, at least. Doing this within a protected action is not a good idea. One can imagine protected action as a being performed by a task with highest real-time priority. Without OS, considering low-level I/O, like DAQ boards, DMA access etc, the performance penalty might be even higher. > Timing_Events should handle a reasonable number of events in the system. > If your application has millions of these firing all over the place, > then scalability could become an issue, and perhaps for such a system, > some alternate design would be more appropriate. No, because these events need to be handled by somewhere. Million events handled by one task? That is the monitor task taking the shortest delay from a queue of. Million tasks will not work anyway. Speaking generally, IMO, the design should be driven by the worker tasks rather than by events, because the system load is inflicted by the workers, not by event propagation. An event implemented by protected actions are in effect synchronous or else you have some task that reads out some queue of events. There is no way to work around this. Either you process the event right at the spot it was triggered (=you don't have events at all), or else you postpone event handling to another task later. The bottom line, events need tasks or else do not exist... >> ----------- >> Timing_Events does not have any advantages over delay or asynchronous >> transfer of control. I guess it was provided for some low-level stuff like >> interrupts from hardware timers. However there was already a support for >> interrupts mapped into protected operations, so it really puzzles me why >> Timing_Events were added. > > I see timing events as being potentially useful reusable concurrency > component. > If you ever need something that looks like timing_events, then hopefully > it will save you from having to write your own. It may have utility in > some areas such as discrete event simulation, for example, if you need > something to coordinate multiple tasks and ensure that signalling events > occur and run to completion before before signaling subsequent events. This is IMO a different case, e.g. pulse events. Yes I have an implementation of pulse events. But I don't see why pulse events cannot be signaled from a scheduler task. The event source is unrelated to the way an event is handled. Basically Timing_Events saves you exactly one "scheduler" task, keeping in mind that the implementation of could deploy some hidden task (thread) anyway. It does not save you the worker task(s). -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de