On Fri, 18 Jul 2008 18:37:23 -0700 (PDT), Anh Vo wrote:
> On Jul 18, 9:22 am, "Dmitry A. Kazakov" <mail...@[EMAIL PROTECTED]
>
> wrote:
>> This is IMO not what Maciej wanted, because as Simon has pointed out
>> protected procedures are very limited in what they allowed do and in
how
>> they do it.
>
> Why is Protected Procedure limited for this purpose?
Because it is executed inside a protected action, see RM 9.5.1.
In particular, ada-gem-15 is a bounded error, because it calls to Put_Line
from a declared protected action. Note that Put_Line is potentially
blocking.
Even if Put_Line does not block, its execution time is unacceptable for a
protected action. Protected actions are thought having *semantically* zero
execution time.
[Yes, GNAT allows Put_Line in protected actions for debugging purpose, but
to do it in production code would be a very bad idea.]
>> Another point is that even if that were the context of a task (which is
>> not), it still would be an unsatisfactory design, because
simultaneously
>> triggered actions would block each other when overlapping.
>
> Again, look at the full code in Ada-Gem-15. There is no overlap action
> at all.
It would be if there *officially* existed a task doing the notification
callbacks.
*Unofficially*, depending on the implementation, the compiler might use
one
task for all instances of Timing_Event or system services (like waitable
timers). In both cases you would have one system thread servicing all
callbacks one after another. Certainly, an implementation could choose to
use one task per each Timing_Event instance, but it would rather be
surprising, because there is no reason to do that, as the callback is
declared to fit into a protected action. Well, having said that, on a
multi-core CPU it could make sense to start one timer task for each core,
but I doubt that any Ada vendor would really care. There seems to be
little
use in Ada.Real_Time.Timing_Events except for bare boards with hardware
timer interrupts mapped directly to Timing_Events.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


|