comp.lang.ada
 help / color / mirror / Atom feed
* protected objects and external call
@ 2004-01-22 16:51 Evangelista Sami
  2004-01-22 18:28 ` Robert A Duff
  2004-01-23  8:59 ` Jean-Pierre Rosen
  0 siblings, 2 replies; 6+ messages in thread
From: Evangelista Sami @ 2004-01-22 16:51 UTC (permalink / raw)


hi all

in RM-9.5.1 we see there is a difference between external and internal
protected calls. Let's consider the following code
----------------------------------
protected type Prot is
   procedure P;
end Prot;
My_Prots : array (1..10) of Prot;

protected body Prot is

   procedure P is
   begin
      .....
      My_Prots(5).P;
      ....
   end;

end Prot;
----------------------------------

Is the call "My_Prots(5).P" always considered as an external call or
is it an internal call if the object on which is executed the
procedure is My_Prots(5) ?

Thanks for any help

Sami Evangelista



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

* Re: protected objects and external call
  2004-01-22 16:51 protected objects and external call Evangelista Sami
@ 2004-01-22 18:28 ` Robert A Duff
  2004-01-23  8:59 ` Jean-Pierre Rosen
  1 sibling, 0 replies; 6+ messages in thread
From: Robert A Duff @ 2004-01-22 18:28 UTC (permalink / raw)


evangeli@cnam.fr (Evangelista Sami) writes:

> in RM-9.5.1 we see there is a difference between external and internal
> protected calls. Let's consider the following code
> ----------------------------------
> protected type Prot is
>    procedure P;
> end Prot;
> My_Prots : array (1..10) of Prot;
> 
> protected body Prot is
> 
>    procedure P is
>    begin
>       .....
>       My_Prots(5).P;
>       ....
>    end;
> 
> end Prot;
> ----------------------------------
> 
> Is the call "My_Prots(5).P" always considered as an external call or
> is it an internal call if the object on which is executed the
> procedure is My_Prots(5) ?

Always external.  The rule is in RM-9.5(3-4), and it's based on the form
of name used, not on some sort of run-time decision.

- Bob



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

* Re: protected objects and external call
  2004-01-22 16:51 protected objects and external call Evangelista Sami
  2004-01-22 18:28 ` Robert A Duff
@ 2004-01-23  8:59 ` Jean-Pierre Rosen
  2004-01-23 14:53   ` Robert A Duff
  1 sibling, 1 reply; 6+ messages in thread
From: Jean-Pierre Rosen @ 2004-01-23  8:59 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]


"Evangelista Sami" <evangeli@cnam.fr> a �crit dans le message de news:5f59677c.0401220851.3c2922b0@posting.google.com...
> hi all
>
> in RM-9.5.1 we see there is a difference between external and internal
> protected calls. Let's consider the following code
> ----------------------------------
> protected type Prot is
>    procedure P;
> end Prot;
> My_Prots : array (1..10) of Prot;
>
> protected body Prot is
>
>    procedure P is
>    begin
>       .....
>       My_Prots(5).P;
>       ....
>    end;
>
> end Prot;
> ----------------------------------
>
> Is the call "My_Prots(5).P" always considered as an external call or
> is it an internal call if the object on which is executed the
> procedure is My_Prots(5) ?
>
It is an external call (in the general case, you cannot know statically whether it's truly external or not).
This means that you'll try to grab the lock of the PO again, and this can lead to dead-lock.
This is why it is considered a potentially blocking operation, and as such disallowed in a protected operation.

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





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

* Re: protected objects and external call
  2004-01-23  8:59 ` Jean-Pierre Rosen
@ 2004-01-23 14:53   ` Robert A Duff
  2004-01-23 15:50     ` Jean-Pierre Rosen
  0 siblings, 1 reply; 6+ messages in thread
From: Robert A Duff @ 2004-01-23 14:53 UTC (permalink / raw)


"Jean-Pierre Rosen" <rosen@adalog.fr> writes:

> "Evangelista Sami" <evangeli@cnam.fr> a �crit dans le message de news:5f59677c.0401220851.3c2922b0@posting.google.com...
> > hi all
> >
> > in RM-9.5.1 we see there is a difference between external and internal
> > protected calls. Let's consider the following code
> > ----------------------------------
> > protected type Prot is
> >    procedure P;
> > end Prot;
> > My_Prots : array (1..10) of Prot;
> >
> > protected body Prot is
> >
> >    procedure P is
> >    begin
> >       .....
> >       My_Prots(5).P;
> >       ....
> >    end;
> >
> > end Prot;
> > ----------------------------------
> >
> > Is the call "My_Prots(5).P" always considered as an external call or
> > is it an internal call if the object on which is executed the
> > procedure is My_Prots(5) ?
> >
> It is an external call (in the general case, you cannot know
> statically whether it's truly external or not).

Right.

> This means that you'll try to grab the lock of the PO again, and this
> can lead to dead-lock.

Right.

> This is why it is considered a potentially blocking operation, and as
> such disallowed in a protected operation.

No, I don't think that's quite right.  Entry calls are potentially
blocking, and you're not supposed to call them from inside a protected
procedure.  (Actually, it's a bounded error, and some compilers allow
it.)  But a protected procedure can call another protected procedure
with an external call.  It's up to the programmer to make sure it's not
the same protected object.  (You also have to obey the priority
ceiling rules.)

In other words, merely grabbing the lock of a PO is *not* considered
blocking or potentially blocking in Ada, and no queue-ing need be
involved.

- Bob



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

* Re: protected objects and external call
  2004-01-23 14:53   ` Robert A Duff
@ 2004-01-23 15:50     ` Jean-Pierre Rosen
  2004-01-23 17:19       ` Robert A Duff
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Pierre Rosen @ 2004-01-23 15:50 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]


"Robert A Duff" <bobduff@shell01.TheWorld.com> a �crit dans le message de
> > This is why it is considered a potentially blocking operation, and as
> > such disallowed in a protected operation.
>
> No, I don't think that's quite right.  Entry calls are potentially
> blocking, and you're not supposed to call them from inside a protected
> procedure.  (Actually, it's a bounded error, and some compilers allow
> it.)  But a protected procedure can call another protected procedure
> with an external call.  It's up to the programmer to make sure it's not
> the same protected object.  (You also have to obey the priority
> ceiling rules.)
>
> In other words, merely grabbing the lock of a PO is *not* considered
> blocking or potentially blocking in Ada, and no queue-ing need be
> involved.
>
9.5.1(16): [Potentially blocking operations]
an external call on a protected subprogram (or an external requeue) with the same target object as that of the protected action;

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





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

* Re: protected objects and external call
  2004-01-23 15:50     ` Jean-Pierre Rosen
@ 2004-01-23 17:19       ` Robert A Duff
  0 siblings, 0 replies; 6+ messages in thread
From: Robert A Duff @ 2004-01-23 17:19 UTC (permalink / raw)


"Jean-Pierre Rosen" <rosen@adalog.fr> writes:

> "Robert A Duff" <bobduff@shell01.TheWorld.com> a �crit dans le message de
> > > This is why it is considered a potentially blocking operation, and as
> > > such disallowed in a protected operation.
> >
> > No, I don't think that's quite right.  Entry calls are potentially
> > blocking, and you're not supposed to call them from inside a protected
> > procedure.  (Actually, it's a bounded error, and some compilers allow
> > it.)  But a protected procedure can call another protected procedure
> > with an external call.  It's up to the programmer to make sure it's not
> > the same protected object.  (You also have to obey the priority
> > ceiling rules.)
> >
> > In other words, merely grabbing the lock of a PO is *not* considered
> > blocking or potentially blocking in Ada, and no queue-ing need be
> > involved.
> >
> 9.5.1(16): [Potentially blocking operations]
> an external call on a protected subprogram (or an external requeue)
> with the same target object as that of the protected action;

Ah, thanks, I had forgotten that.  Note that this is *only* talking
about the deadlocking case -- it's just fine to call some other PO's
procedures, and you can't detect this at compile time.  The AARM
explains, "This is really a deadlocking call, not a blocking call...."

- Bob



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

end of thread, other threads:[~2004-01-23 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-22 16:51 protected objects and external call Evangelista Sami
2004-01-22 18:28 ` Robert A Duff
2004-01-23  8:59 ` Jean-Pierre Rosen
2004-01-23 14:53   ` Robert A Duff
2004-01-23 15:50     ` Jean-Pierre Rosen
2004-01-23 17:19       ` Robert A Duff

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