comp.lang.ada
 help / color / mirror / Atom feed
* Can a protected action tie up the calling task?
@ 1997-10-27  0:00 Samuel Mize
  1997-10-28  0:00 ` Tucker Taft
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Mize @ 1997-10-27  0:00 UTC (permalink / raw)



Greetings,

I need to verify a point on how protected actions work.  Please email
me, as my news feed provides *very* variable delays.

My understanding is that, after an entry or procedure completes, the
queues for that object are serviced as far as possible before the
protected action completes.  This is done by any convenient thread of
control (ARM 9.5.3(22)).  This permission ALLOWS but does not REQUIRE
that the task calling the entry or procedure be released before the
protected action completes.

Thus, in the following example, if another task has already called
Complete before task T1 calls Prepare:

- T1's thread of control can execute Complete;

- this COULD keep T1 suspended until Complete terminates.

Example:

     protected Monitor is
      entry Prepare (D: in Data);
      entry Complete;
    private
      Ready_To_Complete: boolean := false;
    end Monitor;

    protected body Monitor is
      entry Prepare (D: in Data)
      when not Ready_To_Complete is
        ...
      entry Complete
      when Ready_To_Complete is
        ...
    end Monitor;

So to ENSURE that T1 can continue processing IMMEDIATELY on completion
of Prepare, we must ensure that Complete is not called before Prepare.
A third entry is probably the simplest way to do this (task T2 calls
Wait_For_Preparation, then Complete).

    protected Monitor is
      entry Prepare (D: in Data);
      entry Wait_For_Preparation;
      procedure Complete;
    private
      Ready_To_Complete: boolean := false;
    end Monitor;

    protected body Monitor is
      entry Prepare (D: in Data)
      when not Ready_To_Complete is
        ...
      entry Wait_For_Preparation
      when Ready_To_Complete is
        ...
      procedure Complete is
        ...
    end Monitor;

Is this correct?  Have I missed something?

Thanks,
Sam Mize

-- 
Samuel Mize -- smize@imagin.net -- Team Ada
(personal net account)




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

end of thread, other threads:[~1997-10-28  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-27  0:00 Can a protected action tie up the calling task? Samuel Mize
1997-10-28  0:00 ` Tucker Taft

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