comp.lang.ada
 help / color / mirror / Atom feed
* implementation approach
@ 2002-07-31  2:54 Mark
  2002-07-31 13:59 ` SteveD
  2002-08-01 19:18 ` Stephen Leake
  0 siblings, 2 replies; 3+ messages in thread
From: Mark @ 2002-07-31  2:54 UTC (permalink / raw)


I'm in a quandry here and could certainly use some help.  That said,
some background information.

I've got code spread across two processors.  We'll call processors A
and B respectively.  Of interest is a device I'm communicating with
(serial).  The code for communicating with said device resides on
processor A.
While communicating with the device during a 'certain' mode, the
communication is as follows:
 - I send a command.
 - Device sends an interrupt 
 - I synchronize with interrupt and send said command again 
 -- and so on ..

Trouble is.  The interrupt gets routed through and FPGA and 'goes'
through processor B.

On B i've got an interrupt handler .. "pragma Attach_Handler .."
that'll check if the interrupt happened.  When it does I could perhaps
set a flag, then pass the message via a Send_Message routine to
processor A and the routine for commanding the device on A will again
command device.

After 8 months of ADA I'm startign to catch on, however, my ADA is
still 'limited'.  In any event, I'm thinking a semaphore might might
be the most elegant approach or ... I'm open for ideas.
If semaphore could someone provide me with an example on how to do
this?

I suspect I'll need two semaphores on both processors.  Once the flag
gets passed from processor B to processor A, the routine in A will
enter the semaphore command the device, release the flag, etc.

Thanks in advance



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: implementation approach
  2002-07-31  2:54 implementation approach Mark
@ 2002-07-31 13:59 ` SteveD
  2002-08-01 19:18 ` Stephen Leake
  1 sibling, 0 replies; 3+ messages in thread
From: SteveD @ 2002-07-31 13:59 UTC (permalink / raw)


"Mark" <ma740988@pegasus.cc.ucf.edu> wrote in message
news:a5ae824.0207301854.3295f3a2@posting.google.com...
[snip]
>
> I suspect I'll need two semaphores on both processors.  Once the flag
> gets passed from processor B to processor A, the routine in A will
> enter the semaphore command the device, release the flag, etc.
>
> Thanks in advance

In Ada an interrupt is associated with a protected procedure in a protected
type.  An example of how to set this up is in the LRM C.3.2(28).

I haven't done any Ada Interrupt handling myself, but I believe this is the
way it's done.

With Ada.Interrupts;

Package Body Interrupt_Test Is

  Protected Type Device_Interface(Int_Id : Ada.Interrupts.Interrupt_ID) Is
    Procedure Handler;
    Pragma Attach_Handler( Handler, Int_Id );
    Entry Wait_Interrupt;
  Private
    Occurred : Boolean := False;
  End Device_Interface;

  Protected Body Device_Interface Is
    Procedure Handler Is
    Begin
      Occurred := TRUE;
    End Handler;
    Entry Wait_Interrupt When Occurred Is
    Begin
      Occurred := False;
    End Wait_Interrupt;
  End Device_Interface;

  Device_1_Driver : Device_Interface( 1 );

  Task Relay Is
  End Relay;

  Task Body Relay Is
  Begin
    Loop
      Device_1_Driver.Wait_Interrupt;
      -- Do something when the interrupt occurs
    End Loop;
  End Relay;

End Interrupt_Test;


I hope this helps,
SteveD





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: implementation approach
  2002-07-31  2:54 implementation approach Mark
  2002-07-31 13:59 ` SteveD
@ 2002-08-01 19:18 ` Stephen Leake
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Leake @ 2002-08-01 19:18 UTC (permalink / raw)


ma740988@pegasus.cc.ucf.edu (Mark) writes:

> I'm in a quandry here and could certainly use some help.  That said,
> some background information.
> 
> I've got code spread across two processors.  We'll call processors A
> and B respectively.  Of interest is a device I'm communicating with
> (serial).  The code for communicating with said device resides on
> processor A.
> While communicating with the device during a 'certain' mode, the
> communication is as follows:
>  - I send a command.
>  - Device sends an interrupt 
>  - I synchronize with interrupt and send said command again 
>  -- and so on ..
> 
> Trouble is.  The interrupt gets routed through and FPGA and 'goes'
> through processor B.

Hmm. Have you tried saying "Either the serial port needs to be
commanded from processor B, or the interrupt needs to be handled by
processor A".

Why can't processor B command the serial port?

Why can't the hardware design be changed so processor A handles the
interrupt?

Always try to do it right, first!

> On B i've got an interrupt handler .. "pragma Attach_Handler .."
> that'll check if the interrupt happened. When it does I could
> perhaps set a flag, then pass the message via a Send_Message routine
> to processor A and the routine for commanding the device on A will
> again command device.

This makes sense. 

> After 8 months of ADA I'm startign to catch on, however, my ADA is
> still 'limited'. In any event, I'm thinking a semaphore might might
> be the most elegant approach or ... I'm open for ideas. If semaphore
> could someone provide me with an example on how to do this?

You'll have to look in your operating system manuals to see what is
provided. (the "non-Ada", but probably simpler, way).

Or, look in the Distributed Systems Annex to see what is available
there. (the "Ada way").

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-01 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-31  2:54 implementation approach Mark
2002-07-31 13:59 ` SteveD
2002-08-01 19:18 ` Stephen Leake

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