Re: protected type interrupts



REH wrote:
Adam Beneschan wrote:
REH wrote:

Thanks for the reference. Is your work-around valid? Isn't calling
Relay_Object.Isr a potentially blocking operation, and thus a bad thing
to do in an interrupt?

I don't think it's potentially blocking... Relay_Object.Isr is a
procedure, and as I read 9.5.1, a call to a protected *procedure* is
not a potentially blocking operation unless it's done from the same
protected object. A call on a protected *entry* would be potentially
blocking. [This is from the Ada 95 manual. If this has changed in Ada
0Y, I can't tell because www.adaic.com isn't responding.]


I don't understand. How can a procedure within a protected object
modify data internal to the object in a thread-safe way without the
potentially blocking effect of enforcing mutual exclusion? If one task
is "using" the object, and another calls one of the object's
procedures, would the second task not be blocked until the first one
exits the object?

I'm just reading what the RM says. But, although I'm not an expert at
this, I don't believe your argument makes sense given the way protected
objects are supposed to work. A task cannot, of course, access data
internal to a protected object directly; it has to call one of the PO's
subprograms or entries to get it. When it does so, then assuming
Ceiling_Locking is in effect, no other task can use the PO---but it's
not because other tasks are blocked, it's simply because the protected
action runs at a higher priority than any task that could use the PO
(and the protected action is supposed to complete very quickly). So no
mutual exclusion or blocking is necessary when calling protected
subprograms. At least I think that's how it works.

-- Adam

.



Relevant Pages

  • Re: Barrier re-evaluation issue with GNAT 4.3.2
    ... this code contains a bounded error. ... the potentially blocking operation was detected, ... Thanks for the clarification and the pointer to the ARM. ...
    (comp.lang.ada)
  • Re: protected objects and external call
    ... >> This is why it is considered a potentially blocking operation, ... But a protected procedure can call another protected procedure ... > the same protected object. ...
    (comp.lang.ada)
  • Re: protected type interrupts
    ... Relay_Object.Isr a potentially blocking operation, ... How can a procedure within a protected object ... would the second task not be blocked until the first one ...
    (comp.lang.ada)
  • Re: Need a Sanity Check
    ... During a protected action, it is a bounded error to invoke an operation that is potentially blocking. ...
    (comp.lang.ada)
  • Re: requeue with abort and timed call
    ... Dmitry A. Kazakov wrote: ... is not potentially blocking. ... protected action, ... I think the ARM gives the implementation the right to decide whether or not to raise an exception if it detects the problem. ...
    (comp.lang.ada)