comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: [Ravenscar] run tasks on events
Date: Fri, 30 May 2008 13:47:14 +0300
Date: 2008-05-30T13:47:14+03:00	[thread overview]
Message-ID: <483fdadf$0$2672$4f793bc4@news.tdc.fi> (raw)
In-Reply-To: <g1ofgv$qgg$1@news.lrz-muenchen.de>

Sebastian Hanigk wrote:
> Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
> 
> 
>>Anh Vo wrote:
>>
>>>It is not true. Protected entry, implemented in Transient
>>>Signals for example, can suspend/release multiple tasks.
>>
>>True in unrestricted Ada (an entry queue can hold many tasks), false
>>under the Ravenscar profile (maximum one task waiting on an entry). If
>>you use protected objects to trigger tasks, you need one object per
>>task.
> 
> 
> Argh. Seems I was too early in my reply to Anh Vo ...
> 
> Shouldn't there be a constraint error?

Acccording to LRM D.7.19(1/2), violation of Max_Entry_Queue_Length 
raises Program_Error at the violating entry call.

In unrestricted Ada, if an exception occurs in a task, and the task 
does not handle the exception, the task by default terminates 
silently when the exception propagates out of the task. If you want 
to know about exceptions in a task, you should put a last-chance, 
catch-all exception handler in the task body ("exception when 
others => ...").

Since the Ravenscar profile contains the restriction 
No_Task_Termination, by LRM D.7.15(1/2) it is implementation 
defined what happens when a Ravenscar task terminates due to an 
unhandled exception or for other reasons. It may be reported or 
signalled in some way, or not.

> I hadn't included the Profile pragma in all my source files, so I'm
> assuming that the successful test earlier on was due to not complying
> with the Ravenscar profile. Having put the pragma directives into the
> source code, now only one of the waiting tasks resumes/suspends.

The Profile pragma is a "configuration" pragma. If you use Gnat, 
you should normally put configuration pragmas in a separate file 
called "gnat.adc", and Gnat will then include them in all 
compilations. See the GNAT User Guide; I haven't used such pragmas 
myself, so I'm not expert.

> Well, I found the signaling/scheduling concept very elegant; now it
> seems my best bet would be a check inside each task's loop if the
> respective conditions evaluate to True, otherwise simply delay until the
> next period.

That is a good solution for periodic tasks, where the task is 
triggered by "delay until" and not by an event. Of course you will 
waste some processor time on unnecessary activations of the task. 
To avoid that, make the task suspend itself on a suspension object 
(a different object for each task) when the task has nothing to do. 
The "elegance" of this solution is subjective, of course, but I 
don't find it very ugly to have a different object for each task; 
it even makes it easier to select the subset of tasks that should 
become active.

Note also that transitions between phases or modes must be planned 
and implemented carefully, perhaps over more than one task cycle, 
to avoid transients (both control transients and 
performance/deadline transients) during the transition.

HTH,

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  reply	other threads:[~2008-05-30 10:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-28 19:14 [Ravenscar] run tasks on events Sebastian Hanigk
2008-05-28 23:47 ` jimmaureenrogers
2008-05-29 10:35   ` Sebastian Hanigk
2008-05-29  3:16 ` ahab
2008-05-29 10:31   ` Sebastian Hanigk
2008-05-29 18:56     ` Anh Vo
2008-05-30  6:56       ` Sebastian Hanigk
2008-05-30  7:26 ` [Ravenscar] " Niklas Holsti
2008-05-30  8:57   ` Sebastian Hanigk
2008-05-30 10:47     ` Niklas Holsti [this message]
2008-05-30 11:17       ` Sebastian Hanigk
2008-05-30 15:24         ` Alex R. Mosteo
2008-05-30 15:35           ` Ed Falis
2008-05-30 18:02             ` Sebastian Hanigk
2008-05-30 18:11               ` Ed Falis
2008-05-30 11:59       ` stefan-lucks
2008-05-30 12:17 ` jimmaureenrogers
2008-05-30 18:59   ` Sebastian Hanigk
2008-06-02 10:32     ` Alex R. Mosteo
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox