From: "Pat Rogers" <progers@NOclasswideSPAM.com>
Subject: Re: Connecting To Interrupts Using Protected Procedures
Date: 1999/02/18
Date: 1999-02-18T00:00:00+00:00 [thread overview]
Message-ID: <7ahak3$95s$1@remarQ.com> (raw)
In-Reply-To: 7aftch$bn8$1@remarQ.com
Marin wrote:
>>Now Ada95 allows this as per ARM J.7.1 etc. but given that it is
>>considered obsolete, I'd like to do it by the preferred method. So
I've
>>looked at connecting the 1ms interrupt to a protected procedure and
this
>>all looks pretty straightforward. The problem is getting this
protected
>>procedure to periodically kick off the slower cycle task. According
to
>>ARM 9.5.1(8..17) you can't call an entry from there without creating
a
>>bounded error. (Maybe it will run, but only if the system can't
detect
>>it and raise Program_Error.) So how is it that the protected
procedure
>>should communicate to the slower task to start cycling? You want the
>>slower task to be blocked until its time cycle comes around again,
so
>>you would naturally think of some form of entry - but so far as I
can
>>see, I've got no way of legally doing that. I suppose one could poll
a
>>shared variable until the interrupt handler set the flag, but
polling
>>answers are just not practical in this arena. (Ideally, you would
want
>>to implement this with a clock and a delay statement, but the
hardware
>>doesn't support this at the moment.)
and I wrote:
>It sounds like you should have the slower task call and suspend on an
>entry in the interrupt handler protected object, and have the
>interrupt handler procedure set a flag (inside that same PO) that
>allows that entry call to proceed whenever appropriate (ie on the Nth
>cycle). The flag is false until the interrupt handler (procedure)
>determines that it is appropriate for the task to return from the
>call.
Since you asked for a snippet of code:
with System;
with Ada.Interrupts;
package IO is
N : constant := 1000; -- whatever
Device_Priority : constant System.Interrupt_Priority :=
System.Interrupt_Priority'Last; -- whatever
Device_Id : constant Ada.Interrupts.Interrupt_Id := 0; --
whatever
protected Handler is
entry Wait;
pragma Interrupt_Priority( Device_Priority );
private
procedure Handle_Interrupt;
pragma Attach_Handler( Handle_Interrupt, Device_Id );
Count : Integer range 0 .. N := 0;
Enable_Waiting_Caller : Boolean := False;
end Handler;
end IO;
package body IO is
protected body Handler is
entry Wait when Enable_Waiting_Caller is
begin
Count := 0;
Enable_Waiting_Caller := False;
end Wait;
procedure Handle_Interrupt is
begin
-- do stuff, including incrementing Count
if Count = N then
Enable_Waiting_Caller := True;
end if;
end Handle_Interrupt;
end Handler;
end IO;
next prev parent reply other threads:[~1999-02-18 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-02-17 0:00 Connecting To Interrupts Using Protected Procedures Marin David Condic
1999-02-17 0:00 ` Pat Rogers
1999-02-18 0:00 ` Pat Rogers [this message]
1999-02-18 0:00 ` Marin David Condic
1999-02-18 0:00 ` Matthew Heaney
1999-02-18 0:00 ` robert_dewar
1999-02-18 0:00 ` Marin David Condic
1999-02-18 0:00 ` robert_dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox